{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"http://hilpisch.com/tpq_logo.png\" alt=\"The Python Quants\" width=\"35%\" align=\"right\" border=\"0\"><br>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Python for Finance (2nd ed.)\n",
    "\n",
    "**Mastering Data-Driven Finance**\n",
    "\n",
    "&copy; Dr. Yves J. Hilpisch | The Python Quants GmbH\n",
    "\n",
    "<img src=\"http://hilpisch.com/images/py4fi_2nd_shadow.png\" width=\"300px\" align=\"left\">"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Performance Python"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Loops"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def average_py(n):\n",
    "    s = 0  \n",
    "    for i in range(n):\n",
    "        s += random.random()  \n",
    "    return s / n  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "n = 10000000  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1.02 s, sys: 3.99 ms, total: 1.02 s\n",
      "Wall time: 1.02 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.4998757521269353"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time average_py(n)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "961 ms ± 21.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ]
    }
   ],
   "source": [
    "%timeit average_py(n)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1.19 s, sys: 206 ms, total: 1.4 s\n",
      "Wall time: 1.41 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.5000705515718292"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time sum([random.random() for _ in range(n)]) / n  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### NumPy "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "def average_np(n):\n",
    "    s = np.random.random(n)  \n",
    "    return s.mean()  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 71.1 ms, sys: 24.5 ms, total: 95.6 ms\n",
      "Wall time: 94.4 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.5002203326147157"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time average_np(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "62.3 ms ± 1.44 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit average_np(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "80000000"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = np.random.random(n)\n",
    "s.nbytes  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Numba"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numba"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "average_nb = numba.jit(average_py)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 242 ms, sys: 48.3 ms, total: 290 ms\n",
      "Wall time: 2.96 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.5001103429869999"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time average_nb(n)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 36.9 ms, sys: 164 µs, total: 37.1 ms\n",
      "Wall time: 37.1 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.4999914918245189"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time average_nb(n)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "39 ms ± 896 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit average_nb(n)  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cython"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext Cython"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<!-- Generated by Cython 0.29.24 -->\n",
       "<html>\n",
       "<head>\n",
       "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n",
       "    <title>Cython: _cython_magic_6afa678089a5ad7feef94d001e38d801.pyx</title>\n",
       "    <style type=\"text/css\">\n",
       "    \n",
       "body.cython { font-family: courier; font-size: 12; }\n",
       "\n",
       ".cython.tag  {  }\n",
       ".cython.line { margin: 0em }\n",
       ".cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; }\n",
       "\n",
       ".cython.line .run { background-color: #B0FFB0; }\n",
       ".cython.line .mis { background-color: #FFB0B0; }\n",
       ".cython.code.run  { border-left: 8px solid #B0FFB0; }\n",
       ".cython.code.mis  { border-left: 8px solid #FFB0B0; }\n",
       "\n",
       ".cython.code .py_c_api  { color: red; }\n",
       ".cython.code .py_macro_api  { color: #FF7000; }\n",
       ".cython.code .pyx_c_api  { color: #FF3000; }\n",
       ".cython.code .pyx_macro_api  { color: #FF7000; }\n",
       ".cython.code .refnanny  { color: #FFA000; }\n",
       ".cython.code .trace  { color: #FFA000; }\n",
       ".cython.code .error_goto  { color: #FFA000; }\n",
       "\n",
       ".cython.code .coerce  { color: #008000; border: 1px dotted #008000 }\n",
       ".cython.code .py_attr { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_attr  { color: #0000FF; }\n",
       ".cython.code .py_call { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_call  { color: #0000FF; }\n",
       "\n",
       ".cython.score-0 {background-color: #FFFFff;}\n",
       ".cython.score-1 {background-color: #FFFFe7;}\n",
       ".cython.score-2 {background-color: #FFFFd4;}\n",
       ".cython.score-3 {background-color: #FFFFc4;}\n",
       ".cython.score-4 {background-color: #FFFFb6;}\n",
       ".cython.score-5 {background-color: #FFFFaa;}\n",
       ".cython.score-6 {background-color: #FFFF9f;}\n",
       ".cython.score-7 {background-color: #FFFF96;}\n",
       ".cython.score-8 {background-color: #FFFF8d;}\n",
       ".cython.score-9 {background-color: #FFFF86;}\n",
       ".cython.score-10 {background-color: #FFFF7f;}\n",
       ".cython.score-11 {background-color: #FFFF79;}\n",
       ".cython.score-12 {background-color: #FFFF73;}\n",
       ".cython.score-13 {background-color: #FFFF6e;}\n",
       ".cython.score-14 {background-color: #FFFF6a;}\n",
       ".cython.score-15 {background-color: #FFFF66;}\n",
       ".cython.score-16 {background-color: #FFFF62;}\n",
       ".cython.score-17 {background-color: #FFFF5e;}\n",
       ".cython.score-18 {background-color: #FFFF5b;}\n",
       ".cython.score-19 {background-color: #FFFF57;}\n",
       ".cython.score-20 {background-color: #FFFF55;}\n",
       ".cython.score-21 {background-color: #FFFF52;}\n",
       ".cython.score-22 {background-color: #FFFF4f;}\n",
       ".cython.score-23 {background-color: #FFFF4d;}\n",
       ".cython.score-24 {background-color: #FFFF4b;}\n",
       ".cython.score-25 {background-color: #FFFF48;}\n",
       ".cython.score-26 {background-color: #FFFF46;}\n",
       ".cython.score-27 {background-color: #FFFF44;}\n",
       ".cython.score-28 {background-color: #FFFF43;}\n",
       ".cython.score-29 {background-color: #FFFF41;}\n",
       ".cython.score-30 {background-color: #FFFF3f;}\n",
       ".cython.score-31 {background-color: #FFFF3e;}\n",
       ".cython.score-32 {background-color: #FFFF3c;}\n",
       ".cython.score-33 {background-color: #FFFF3b;}\n",
       ".cython.score-34 {background-color: #FFFF39;}\n",
       ".cython.score-35 {background-color: #FFFF38;}\n",
       ".cython.score-36 {background-color: #FFFF37;}\n",
       ".cython.score-37 {background-color: #FFFF36;}\n",
       ".cython.score-38 {background-color: #FFFF35;}\n",
       ".cython.score-39 {background-color: #FFFF34;}\n",
       ".cython.score-40 {background-color: #FFFF33;}\n",
       ".cython.score-41 {background-color: #FFFF32;}\n",
       ".cython.score-42 {background-color: #FFFF31;}\n",
       ".cython.score-43 {background-color: #FFFF30;}\n",
       ".cython.score-44 {background-color: #FFFF2f;}\n",
       ".cython.score-45 {background-color: #FFFF2e;}\n",
       ".cython.score-46 {background-color: #FFFF2d;}\n",
       ".cython.score-47 {background-color: #FFFF2c;}\n",
       ".cython.score-48 {background-color: #FFFF2b;}\n",
       ".cython.score-49 {background-color: #FFFF2b;}\n",
       ".cython.score-50 {background-color: #FFFF2a;}\n",
       ".cython.score-51 {background-color: #FFFF29;}\n",
       ".cython.score-52 {background-color: #FFFF29;}\n",
       ".cython.score-53 {background-color: #FFFF28;}\n",
       ".cython.score-54 {background-color: #FFFF27;}\n",
       ".cython.score-55 {background-color: #FFFF27;}\n",
       ".cython.score-56 {background-color: #FFFF26;}\n",
       ".cython.score-57 {background-color: #FFFF26;}\n",
       ".cython.score-58 {background-color: #FFFF25;}\n",
       ".cython.score-59 {background-color: #FFFF24;}\n",
       ".cython.score-60 {background-color: #FFFF24;}\n",
       ".cython.score-61 {background-color: #FFFF23;}\n",
       ".cython.score-62 {background-color: #FFFF23;}\n",
       ".cython.score-63 {background-color: #FFFF22;}\n",
       ".cython.score-64 {background-color: #FFFF22;}\n",
       ".cython.score-65 {background-color: #FFFF22;}\n",
       ".cython.score-66 {background-color: #FFFF21;}\n",
       ".cython.score-67 {background-color: #FFFF21;}\n",
       ".cython.score-68 {background-color: #FFFF20;}\n",
       ".cython.score-69 {background-color: #FFFF20;}\n",
       ".cython.score-70 {background-color: #FFFF1f;}\n",
       ".cython.score-71 {background-color: #FFFF1f;}\n",
       ".cython.score-72 {background-color: #FFFF1f;}\n",
       ".cython.score-73 {background-color: #FFFF1e;}\n",
       ".cython.score-74 {background-color: #FFFF1e;}\n",
       ".cython.score-75 {background-color: #FFFF1e;}\n",
       ".cython.score-76 {background-color: #FFFF1d;}\n",
       ".cython.score-77 {background-color: #FFFF1d;}\n",
       ".cython.score-78 {background-color: #FFFF1c;}\n",
       ".cython.score-79 {background-color: #FFFF1c;}\n",
       ".cython.score-80 {background-color: #FFFF1c;}\n",
       ".cython.score-81 {background-color: #FFFF1c;}\n",
       ".cython.score-82 {background-color: #FFFF1b;}\n",
       ".cython.score-83 {background-color: #FFFF1b;}\n",
       ".cython.score-84 {background-color: #FFFF1b;}\n",
       ".cython.score-85 {background-color: #FFFF1a;}\n",
       ".cython.score-86 {background-color: #FFFF1a;}\n",
       ".cython.score-87 {background-color: #FFFF1a;}\n",
       ".cython.score-88 {background-color: #FFFF1a;}\n",
       ".cython.score-89 {background-color: #FFFF19;}\n",
       ".cython.score-90 {background-color: #FFFF19;}\n",
       ".cython.score-91 {background-color: #FFFF19;}\n",
       ".cython.score-92 {background-color: #FFFF19;}\n",
       ".cython.score-93 {background-color: #FFFF18;}\n",
       ".cython.score-94 {background-color: #FFFF18;}\n",
       ".cython.score-95 {background-color: #FFFF18;}\n",
       ".cython.score-96 {background-color: #FFFF18;}\n",
       ".cython.score-97 {background-color: #FFFF17;}\n",
       ".cython.score-98 {background-color: #FFFF17;}\n",
       ".cython.score-99 {background-color: #FFFF17;}\n",
       ".cython.score-100 {background-color: #FFFF17;}\n",
       ".cython.score-101 {background-color: #FFFF16;}\n",
       ".cython.score-102 {background-color: #FFFF16;}\n",
       ".cython.score-103 {background-color: #FFFF16;}\n",
       ".cython.score-104 {background-color: #FFFF16;}\n",
       ".cython.score-105 {background-color: #FFFF16;}\n",
       ".cython.score-106 {background-color: #FFFF15;}\n",
       ".cython.score-107 {background-color: #FFFF15;}\n",
       ".cython.score-108 {background-color: #FFFF15;}\n",
       ".cython.score-109 {background-color: #FFFF15;}\n",
       ".cython.score-110 {background-color: #FFFF15;}\n",
       ".cython.score-111 {background-color: #FFFF15;}\n",
       ".cython.score-112 {background-color: #FFFF14;}\n",
       ".cython.score-113 {background-color: #FFFF14;}\n",
       ".cython.score-114 {background-color: #FFFF14;}\n",
       ".cython.score-115 {background-color: #FFFF14;}\n",
       ".cython.score-116 {background-color: #FFFF14;}\n",
       ".cython.score-117 {background-color: #FFFF14;}\n",
       ".cython.score-118 {background-color: #FFFF13;}\n",
       ".cython.score-119 {background-color: #FFFF13;}\n",
       ".cython.score-120 {background-color: #FFFF13;}\n",
       ".cython.score-121 {background-color: #FFFF13;}\n",
       ".cython.score-122 {background-color: #FFFF13;}\n",
       ".cython.score-123 {background-color: #FFFF13;}\n",
       ".cython.score-124 {background-color: #FFFF13;}\n",
       ".cython.score-125 {background-color: #FFFF12;}\n",
       ".cython.score-126 {background-color: #FFFF12;}\n",
       ".cython.score-127 {background-color: #FFFF12;}\n",
       ".cython.score-128 {background-color: #FFFF12;}\n",
       ".cython.score-129 {background-color: #FFFF12;}\n",
       ".cython.score-130 {background-color: #FFFF12;}\n",
       ".cython.score-131 {background-color: #FFFF12;}\n",
       ".cython.score-132 {background-color: #FFFF11;}\n",
       ".cython.score-133 {background-color: #FFFF11;}\n",
       ".cython.score-134 {background-color: #FFFF11;}\n",
       ".cython.score-135 {background-color: #FFFF11;}\n",
       ".cython.score-136 {background-color: #FFFF11;}\n",
       ".cython.score-137 {background-color: #FFFF11;}\n",
       ".cython.score-138 {background-color: #FFFF11;}\n",
       ".cython.score-139 {background-color: #FFFF11;}\n",
       ".cython.score-140 {background-color: #FFFF11;}\n",
       ".cython.score-141 {background-color: #FFFF10;}\n",
       ".cython.score-142 {background-color: #FFFF10;}\n",
       ".cython.score-143 {background-color: #FFFF10;}\n",
       ".cython.score-144 {background-color: #FFFF10;}\n",
       ".cython.score-145 {background-color: #FFFF10;}\n",
       ".cython.score-146 {background-color: #FFFF10;}\n",
       ".cython.score-147 {background-color: #FFFF10;}\n",
       ".cython.score-148 {background-color: #FFFF10;}\n",
       ".cython.score-149 {background-color: #FFFF10;}\n",
       ".cython.score-150 {background-color: #FFFF0f;}\n",
       ".cython.score-151 {background-color: #FFFF0f;}\n",
       ".cython.score-152 {background-color: #FFFF0f;}\n",
       ".cython.score-153 {background-color: #FFFF0f;}\n",
       ".cython.score-154 {background-color: #FFFF0f;}\n",
       ".cython.score-155 {background-color: #FFFF0f;}\n",
       ".cython.score-156 {background-color: #FFFF0f;}\n",
       ".cython.score-157 {background-color: #FFFF0f;}\n",
       ".cython.score-158 {background-color: #FFFF0f;}\n",
       ".cython.score-159 {background-color: #FFFF0f;}\n",
       ".cython.score-160 {background-color: #FFFF0f;}\n",
       ".cython.score-161 {background-color: #FFFF0e;}\n",
       ".cython.score-162 {background-color: #FFFF0e;}\n",
       ".cython.score-163 {background-color: #FFFF0e;}\n",
       ".cython.score-164 {background-color: #FFFF0e;}\n",
       ".cython.score-165 {background-color: #FFFF0e;}\n",
       ".cython.score-166 {background-color: #FFFF0e;}\n",
       ".cython.score-167 {background-color: #FFFF0e;}\n",
       ".cython.score-168 {background-color: #FFFF0e;}\n",
       ".cython.score-169 {background-color: #FFFF0e;}\n",
       ".cython.score-170 {background-color: #FFFF0e;}\n",
       ".cython.score-171 {background-color: #FFFF0e;}\n",
       ".cython.score-172 {background-color: #FFFF0e;}\n",
       ".cython.score-173 {background-color: #FFFF0d;}\n",
       ".cython.score-174 {background-color: #FFFF0d;}\n",
       ".cython.score-175 {background-color: #FFFF0d;}\n",
       ".cython.score-176 {background-color: #FFFF0d;}\n",
       ".cython.score-177 {background-color: #FFFF0d;}\n",
       ".cython.score-178 {background-color: #FFFF0d;}\n",
       ".cython.score-179 {background-color: #FFFF0d;}\n",
       ".cython.score-180 {background-color: #FFFF0d;}\n",
       ".cython.score-181 {background-color: #FFFF0d;}\n",
       ".cython.score-182 {background-color: #FFFF0d;}\n",
       ".cython.score-183 {background-color: #FFFF0d;}\n",
       ".cython.score-184 {background-color: #FFFF0d;}\n",
       ".cython.score-185 {background-color: #FFFF0d;}\n",
       ".cython.score-186 {background-color: #FFFF0d;}\n",
       ".cython.score-187 {background-color: #FFFF0c;}\n",
       ".cython.score-188 {background-color: #FFFF0c;}\n",
       ".cython.score-189 {background-color: #FFFF0c;}\n",
       ".cython.score-190 {background-color: #FFFF0c;}\n",
       ".cython.score-191 {background-color: #FFFF0c;}\n",
       ".cython.score-192 {background-color: #FFFF0c;}\n",
       ".cython.score-193 {background-color: #FFFF0c;}\n",
       ".cython.score-194 {background-color: #FFFF0c;}\n",
       ".cython.score-195 {background-color: #FFFF0c;}\n",
       ".cython.score-196 {background-color: #FFFF0c;}\n",
       ".cython.score-197 {background-color: #FFFF0c;}\n",
       ".cython.score-198 {background-color: #FFFF0c;}\n",
       ".cython.score-199 {background-color: #FFFF0c;}\n",
       ".cython.score-200 {background-color: #FFFF0c;}\n",
       ".cython.score-201 {background-color: #FFFF0c;}\n",
       ".cython.score-202 {background-color: #FFFF0c;}\n",
       ".cython.score-203 {background-color: #FFFF0b;}\n",
       ".cython.score-204 {background-color: #FFFF0b;}\n",
       ".cython.score-205 {background-color: #FFFF0b;}\n",
       ".cython.score-206 {background-color: #FFFF0b;}\n",
       ".cython.score-207 {background-color: #FFFF0b;}\n",
       ".cython.score-208 {background-color: #FFFF0b;}\n",
       ".cython.score-209 {background-color: #FFFF0b;}\n",
       ".cython.score-210 {background-color: #FFFF0b;}\n",
       ".cython.score-211 {background-color: #FFFF0b;}\n",
       ".cython.score-212 {background-color: #FFFF0b;}\n",
       ".cython.score-213 {background-color: #FFFF0b;}\n",
       ".cython.score-214 {background-color: #FFFF0b;}\n",
       ".cython.score-215 {background-color: #FFFF0b;}\n",
       ".cython.score-216 {background-color: #FFFF0b;}\n",
       ".cython.score-217 {background-color: #FFFF0b;}\n",
       ".cython.score-218 {background-color: #FFFF0b;}\n",
       ".cython.score-219 {background-color: #FFFF0b;}\n",
       ".cython.score-220 {background-color: #FFFF0b;}\n",
       ".cython.score-221 {background-color: #FFFF0b;}\n",
       ".cython.score-222 {background-color: #FFFF0a;}\n",
       ".cython.score-223 {background-color: #FFFF0a;}\n",
       ".cython.score-224 {background-color: #FFFF0a;}\n",
       ".cython.score-225 {background-color: #FFFF0a;}\n",
       ".cython.score-226 {background-color: #FFFF0a;}\n",
       ".cython.score-227 {background-color: #FFFF0a;}\n",
       ".cython.score-228 {background-color: #FFFF0a;}\n",
       ".cython.score-229 {background-color: #FFFF0a;}\n",
       ".cython.score-230 {background-color: #FFFF0a;}\n",
       ".cython.score-231 {background-color: #FFFF0a;}\n",
       ".cython.score-232 {background-color: #FFFF0a;}\n",
       ".cython.score-233 {background-color: #FFFF0a;}\n",
       ".cython.score-234 {background-color: #FFFF0a;}\n",
       ".cython.score-235 {background-color: #FFFF0a;}\n",
       ".cython.score-236 {background-color: #FFFF0a;}\n",
       ".cython.score-237 {background-color: #FFFF0a;}\n",
       ".cython.score-238 {background-color: #FFFF0a;}\n",
       ".cython.score-239 {background-color: #FFFF0a;}\n",
       ".cython.score-240 {background-color: #FFFF0a;}\n",
       ".cython.score-241 {background-color: #FFFF0a;}\n",
       ".cython.score-242 {background-color: #FFFF0a;}\n",
       ".cython.score-243 {background-color: #FFFF0a;}\n",
       ".cython.score-244 {background-color: #FFFF0a;}\n",
       ".cython.score-245 {background-color: #FFFF0a;}\n",
       ".cython.score-246 {background-color: #FFFF09;}\n",
       ".cython.score-247 {background-color: #FFFF09;}\n",
       ".cython.score-248 {background-color: #FFFF09;}\n",
       ".cython.score-249 {background-color: #FFFF09;}\n",
       ".cython.score-250 {background-color: #FFFF09;}\n",
       ".cython.score-251 {background-color: #FFFF09;}\n",
       ".cython.score-252 {background-color: #FFFF09;}\n",
       ".cython.score-253 {background-color: #FFFF09;}\n",
       ".cython.score-254 {background-color: #FFFF09;}\n",
       "pre { line-height: 125%; }\n",
       "td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       ".cython .hll { background-color: #ffffcc }\n",
       ".cython { background: #f8f8f8; }\n",
       ".cython .c { color: #408080; font-style: italic } /* Comment */\n",
       ".cython .err { border: 1px solid #FF0000 } /* Error */\n",
       ".cython .k { color: #008000; font-weight: bold } /* Keyword */\n",
       ".cython .o { color: #666666 } /* Operator */\n",
       ".cython .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
       ".cython .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
       ".cython .cp { color: #BC7A00 } /* Comment.Preproc */\n",
       ".cython .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
       ".cython .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
       ".cython .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
       ".cython .gd { color: #A00000 } /* Generic.Deleted */\n",
       ".cython .ge { font-style: italic } /* Generic.Emph */\n",
       ".cython .gr { color: #FF0000 } /* Generic.Error */\n",
       ".cython .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
       ".cython .gi { color: #00A000 } /* Generic.Inserted */\n",
       ".cython .go { color: #888888 } /* Generic.Output */\n",
       ".cython .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
       ".cython .gs { font-weight: bold } /* Generic.Strong */\n",
       ".cython .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
       ".cython .gt { color: #0044DD } /* Generic.Traceback */\n",
       ".cython .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
       ".cython .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
       ".cython .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
       ".cython .kp { color: #008000 } /* Keyword.Pseudo */\n",
       ".cython .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
       ".cython .kt { color: #B00040 } /* Keyword.Type */\n",
       ".cython .m { color: #666666 } /* Literal.Number */\n",
       ".cython .s { color: #BA2121 } /* Literal.String */\n",
       ".cython .na { color: #7D9029 } /* Name.Attribute */\n",
       ".cython .nb { color: #008000 } /* Name.Builtin */\n",
       ".cython .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
       ".cython .no { color: #880000 } /* Name.Constant */\n",
       ".cython .nd { color: #AA22FF } /* Name.Decorator */\n",
       ".cython .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
       ".cython .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
       ".cython .nf { color: #0000FF } /* Name.Function */\n",
       ".cython .nl { color: #A0A000 } /* Name.Label */\n",
       ".cython .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
       ".cython .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
       ".cython .nv { color: #19177C } /* Name.Variable */\n",
       ".cython .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
       ".cython .w { color: #bbbbbb } /* Text.Whitespace */\n",
       ".cython .mb { color: #666666 } /* Literal.Number.Bin */\n",
       ".cython .mf { color: #666666 } /* Literal.Number.Float */\n",
       ".cython .mh { color: #666666 } /* Literal.Number.Hex */\n",
       ".cython .mi { color: #666666 } /* Literal.Number.Integer */\n",
       ".cython .mo { color: #666666 } /* Literal.Number.Oct */\n",
       ".cython .sa { color: #BA2121 } /* Literal.String.Affix */\n",
       ".cython .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
       ".cython .sc { color: #BA2121 } /* Literal.String.Char */\n",
       ".cython .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
       ".cython .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
       ".cython .s2 { color: #BA2121 } /* Literal.String.Double */\n",
       ".cython .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
       ".cython .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
       ".cython .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
       ".cython .sx { color: #008000 } /* Literal.String.Other */\n",
       ".cython .sr { color: #BB6688 } /* Literal.String.Regex */\n",
       ".cython .s1 { color: #BA2121 } /* Literal.String.Single */\n",
       ".cython .ss { color: #19177C } /* Literal.String.Symbol */\n",
       ".cython .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
       ".cython .fm { color: #0000FF } /* Name.Function.Magic */\n",
       ".cython .vc { color: #19177C } /* Name.Variable.Class */\n",
       ".cython .vg { color: #19177C } /* Name.Variable.Global */\n",
       ".cython .vi { color: #19177C } /* Name.Variable.Instance */\n",
       ".cython .vm { color: #19177C } /* Name.Variable.Magic */\n",
       ".cython .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
       "    </style>\n",
       "</head>\n",
       "<body class=\"cython\">\n",
       "<p><span style=\"border-bottom: solid 1px grey;\">Generated by Cython 0.29.24</span></p>\n",
       "<p>\n",
       "    <span style=\"background-color: #FFFF00\">Yellow lines</span> hint at Python interaction.<br />\n",
       "    Click on a line that starts with a \"<code>+</code>\" to see the C code that Cython generated for it.\n",
       "</p>\n",
       "<div class=\"cython\"><pre class=\"cython line score-8\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">1</span>: <span class=\"k\">import</span> <span class=\"nn\">random</span></pre>\n",
       "<pre class='cython code score-8 '>  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_random, 0, 0);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_random, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 1, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "</pre><pre class=\"cython line score-26\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">2</span>: <span class=\"k\">def</span> <span class=\"nf\">average_cy1</span><span class=\"p\">(</span><span class=\"nb\">int</span> <span class=\"n\">n</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-26 '>/* Python wrapper */\n",
       "static PyObject *__pyx_pw_46_cython_magic_6afa678089a5ad7feef94d001e38d801_1average_cy1(PyObject *__pyx_self, PyObject *__pyx_arg_n); /*proto*/\n",
       "static PyMethodDef __pyx_mdef_46_cython_magic_6afa678089a5ad7feef94d001e38d801_1average_cy1 = {\"average_cy1\", (PyCFunction)__pyx_pw_46_cython_magic_6afa678089a5ad7feef94d001e38d801_1average_cy1, METH_O, 0};\n",
       "static PyObject *__pyx_pw_46_cython_magic_6afa678089a5ad7feef94d001e38d801_1average_cy1(PyObject *__pyx_self, PyObject *__pyx_arg_n) {\n",
       "  int __pyx_v_n;\n",
       "  PyObject *__pyx_r = 0;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"average_cy1 (wrapper)\", 0);\n",
       "  assert(__pyx_arg_n); {\n",
       "    __pyx_v_n = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_arg_n); if (unlikely((__pyx_v_n == (int)-1) &amp;&amp; <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 2, __pyx_L3_error)</span>\n",
       "  }\n",
       "  goto __pyx_L4_argument_unpacking_done;\n",
       "  __pyx_L3_error:;\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_6afa678089a5ad7feef94d001e38d801.average_cy1\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return NULL;\n",
       "  __pyx_L4_argument_unpacking_done:;\n",
       "  __pyx_r = __pyx_pf_46_cython_magic_6afa678089a5ad7feef94d001e38d801_average_cy1(__pyx_self, ((int)__pyx_v_n));\n",
       "  int __pyx_lineno = 0;\n",
       "  const char *__pyx_filename = NULL;\n",
       "  int __pyx_clineno = 0;\n",
       "\n",
       "  /* function exit code */\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "\n",
       "static PyObject *__pyx_pf_46_cython_magic_6afa678089a5ad7feef94d001e38d801_average_cy1(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {\n",
       "  CYTHON_UNUSED int __pyx_v_i;\n",
       "  float __pyx_v_s;\n",
       "  PyObject *__pyx_r = NULL;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"average_cy1\", 0);\n",
       "/* … */\n",
       "  /* function exit code */\n",
       "  __pyx_L1_error:;\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_6);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_7);\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_6afa678089a5ad7feef94d001e38d801.average_cy1\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  __pyx_r = NULL;\n",
       "  __pyx_L0:;\n",
       "  <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "/* … */\n",
       "  __pyx_tuple_ = <span class='py_c_api'>PyTuple_Pack</span>(4, __pyx_n_s_n, __pyx_n_s_n, __pyx_n_s_i, __pyx_n_s_s);<span class='error_goto'> if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 2, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple_);\n",
       "  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple_);\n",
       "/* … */\n",
       "  __pyx_t_1 = PyCFunction_NewEx(&amp;__pyx_mdef_46_cython_magic_6afa678089a5ad7feef94d001e38d801_1average_cy1, NULL, __pyx_n_s_cython_magic_6afa678089a5ad7fee);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_average_cy1, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 2, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "</pre><pre class=\"cython line score-0\">&#xA0;<span class=\"\">3</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">int</span> <span class=\"nf\">i</span></pre>\n",
       "<pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">4</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">s</span> <span class=\"o\">=</span> <span class=\"mf\">0</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_s = 0.0;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">5</span>:     <span class=\"k\">for</span> <span class=\"n\">i</span> <span class=\"ow\">in</span> <span class=\"nb\">range</span><span class=\"p\">(</span><span class=\"n\">n</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_t_1 = __pyx_v_n;\n",
       "  __pyx_t_2 = __pyx_t_1;\n",
       "  for (__pyx_t_3 = 0; __pyx_t_3 &lt; __pyx_t_2; __pyx_t_3+=1) {\n",
       "    __pyx_v_i = __pyx_t_3;\n",
       "</pre><pre class=\"cython line score-44\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">6</span>:         <span class=\"n\">s</span> <span class=\"o\">+=</span> <span class=\"n\">random</span><span class=\"o\">.</span><span class=\"n\">random</span><span class=\"p\">()</span></pre>\n",
       "<pre class='cython code score-44 '>    __pyx_t_4 = <span class='py_c_api'>PyFloat_FromDouble</span>(__pyx_v_s);<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);\n",
       "    <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_6, __pyx_n_s_random);<span class='error_goto'> if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);\n",
       "    __pyx_t_7 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_6, __pyx_n_s_random);<span class='error_goto'> if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;\n",
       "    __pyx_t_6 = NULL;\n",
       "    if (CYTHON_UNPACK_METHODS &amp;&amp; unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_7))) {\n",
       "      __pyx_t_6 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_7);\n",
       "      if (likely(__pyx_t_6)) {\n",
       "        PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_7);\n",
       "        <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_6);\n",
       "        <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);\n",
       "        <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_7, function);\n",
       "      }\n",
       "    }\n",
       "    __pyx_t_5 = (__pyx_t_6) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_7, __pyx_t_6) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_7);\n",
       "    <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_6); __pyx_t_6 = 0;\n",
       "    if (unlikely(!__pyx_t_5)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;\n",
       "    __pyx_t_7 = <span class='py_c_api'>PyNumber_InPlaceAdd</span>(__pyx_t_4, __pyx_t_5);<span class='error_goto'> if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;\n",
       "    __pyx_t_8 = __pyx_<span class='py_c_api'>PyFloat_AsFloat</span>(__pyx_t_7); if (unlikely((__pyx_t_8 == (float)-1) &amp;&amp; <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_7); __pyx_t_7 = 0;\n",
       "    __pyx_v_s = __pyx_t_8;\n",
       "  }\n",
       "</pre><pre class=\"cython line score-11\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">7</span>:     <span class=\"k\">return</span> <span class=\"n\">s</span> <span class=\"o\">/</span> <span class=\"n\">n</span></pre>\n",
       "<pre class='cython code score-11 '>  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r);\n",
       "  if (unlikely(__pyx_v_n == 0)) {\n",
       "    <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "    <span class='error_goto'>__PYX_ERR(0, 7, __pyx_L1_error)</span>\n",
       "  }\n",
       "  __pyx_t_7 = <span class='py_c_api'>PyFloat_FromDouble</span>((__pyx_v_s / ((float)__pyx_v_n)));<span class='error_goto'> if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_7);\n",
       "  __pyx_r = __pyx_t_7;\n",
       "  __pyx_t_7 = 0;\n",
       "  goto __pyx_L0;\n",
       "</pre></div></body></html>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%cython -a\n",
    "import random  \n",
    "def average_cy1(int n):  \n",
    "    cdef int i  \n",
    "    cdef float s = 0  \n",
    "    for i in range(n):\n",
    "        s += random.random()\n",
    "    return s / n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 570 ms, sys: 4.14 ms, total: 574 ms\n",
      "Wall time: 573 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.5000243782997131"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time average_cy1(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "569 ms ± 23.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ]
    }
   ],
   "source": [
    "%timeit average_cy1(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.6792964339256287\n",
      "0.934692919254303\n",
      "0.3835020661354065\n",
      "0.5194163918495178\n",
      "0.8309653401374817\n"
     ]
    }
   ],
   "source": [
    "%%cython\n",
    "from libc.stdlib cimport rand  \n",
    "cdef extern from 'limits.h':  \n",
    "    int INT_MAX  \n",
    "cdef int i\n",
    "cdef float rn\n",
    "for i in range(5):\n",
    "    rn = rand() / INT_MAX  \n",
    "    print(rn)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<!-- Generated by Cython 0.29.24 -->\n",
       "<html>\n",
       "<head>\n",
       "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n",
       "    <title>Cython: _cython_magic_8446b33ecac06df0a30f65b520a111dd.pyx</title>\n",
       "    <style type=\"text/css\">\n",
       "    \n",
       "body.cython { font-family: courier; font-size: 12; }\n",
       "\n",
       ".cython.tag  {  }\n",
       ".cython.line { margin: 0em }\n",
       ".cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; }\n",
       "\n",
       ".cython.line .run { background-color: #B0FFB0; }\n",
       ".cython.line .mis { background-color: #FFB0B0; }\n",
       ".cython.code.run  { border-left: 8px solid #B0FFB0; }\n",
       ".cython.code.mis  { border-left: 8px solid #FFB0B0; }\n",
       "\n",
       ".cython.code .py_c_api  { color: red; }\n",
       ".cython.code .py_macro_api  { color: #FF7000; }\n",
       ".cython.code .pyx_c_api  { color: #FF3000; }\n",
       ".cython.code .pyx_macro_api  { color: #FF7000; }\n",
       ".cython.code .refnanny  { color: #FFA000; }\n",
       ".cython.code .trace  { color: #FFA000; }\n",
       ".cython.code .error_goto  { color: #FFA000; }\n",
       "\n",
       ".cython.code .coerce  { color: #008000; border: 1px dotted #008000 }\n",
       ".cython.code .py_attr { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_attr  { color: #0000FF; }\n",
       ".cython.code .py_call { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_call  { color: #0000FF; }\n",
       "\n",
       ".cython.score-0 {background-color: #FFFFff;}\n",
       ".cython.score-1 {background-color: #FFFFe7;}\n",
       ".cython.score-2 {background-color: #FFFFd4;}\n",
       ".cython.score-3 {background-color: #FFFFc4;}\n",
       ".cython.score-4 {background-color: #FFFFb6;}\n",
       ".cython.score-5 {background-color: #FFFFaa;}\n",
       ".cython.score-6 {background-color: #FFFF9f;}\n",
       ".cython.score-7 {background-color: #FFFF96;}\n",
       ".cython.score-8 {background-color: #FFFF8d;}\n",
       ".cython.score-9 {background-color: #FFFF86;}\n",
       ".cython.score-10 {background-color: #FFFF7f;}\n",
       ".cython.score-11 {background-color: #FFFF79;}\n",
       ".cython.score-12 {background-color: #FFFF73;}\n",
       ".cython.score-13 {background-color: #FFFF6e;}\n",
       ".cython.score-14 {background-color: #FFFF6a;}\n",
       ".cython.score-15 {background-color: #FFFF66;}\n",
       ".cython.score-16 {background-color: #FFFF62;}\n",
       ".cython.score-17 {background-color: #FFFF5e;}\n",
       ".cython.score-18 {background-color: #FFFF5b;}\n",
       ".cython.score-19 {background-color: #FFFF57;}\n",
       ".cython.score-20 {background-color: #FFFF55;}\n",
       ".cython.score-21 {background-color: #FFFF52;}\n",
       ".cython.score-22 {background-color: #FFFF4f;}\n",
       ".cython.score-23 {background-color: #FFFF4d;}\n",
       ".cython.score-24 {background-color: #FFFF4b;}\n",
       ".cython.score-25 {background-color: #FFFF48;}\n",
       ".cython.score-26 {background-color: #FFFF46;}\n",
       ".cython.score-27 {background-color: #FFFF44;}\n",
       ".cython.score-28 {background-color: #FFFF43;}\n",
       ".cython.score-29 {background-color: #FFFF41;}\n",
       ".cython.score-30 {background-color: #FFFF3f;}\n",
       ".cython.score-31 {background-color: #FFFF3e;}\n",
       ".cython.score-32 {background-color: #FFFF3c;}\n",
       ".cython.score-33 {background-color: #FFFF3b;}\n",
       ".cython.score-34 {background-color: #FFFF39;}\n",
       ".cython.score-35 {background-color: #FFFF38;}\n",
       ".cython.score-36 {background-color: #FFFF37;}\n",
       ".cython.score-37 {background-color: #FFFF36;}\n",
       ".cython.score-38 {background-color: #FFFF35;}\n",
       ".cython.score-39 {background-color: #FFFF34;}\n",
       ".cython.score-40 {background-color: #FFFF33;}\n",
       ".cython.score-41 {background-color: #FFFF32;}\n",
       ".cython.score-42 {background-color: #FFFF31;}\n",
       ".cython.score-43 {background-color: #FFFF30;}\n",
       ".cython.score-44 {background-color: #FFFF2f;}\n",
       ".cython.score-45 {background-color: #FFFF2e;}\n",
       ".cython.score-46 {background-color: #FFFF2d;}\n",
       ".cython.score-47 {background-color: #FFFF2c;}\n",
       ".cython.score-48 {background-color: #FFFF2b;}\n",
       ".cython.score-49 {background-color: #FFFF2b;}\n",
       ".cython.score-50 {background-color: #FFFF2a;}\n",
       ".cython.score-51 {background-color: #FFFF29;}\n",
       ".cython.score-52 {background-color: #FFFF29;}\n",
       ".cython.score-53 {background-color: #FFFF28;}\n",
       ".cython.score-54 {background-color: #FFFF27;}\n",
       ".cython.score-55 {background-color: #FFFF27;}\n",
       ".cython.score-56 {background-color: #FFFF26;}\n",
       ".cython.score-57 {background-color: #FFFF26;}\n",
       ".cython.score-58 {background-color: #FFFF25;}\n",
       ".cython.score-59 {background-color: #FFFF24;}\n",
       ".cython.score-60 {background-color: #FFFF24;}\n",
       ".cython.score-61 {background-color: #FFFF23;}\n",
       ".cython.score-62 {background-color: #FFFF23;}\n",
       ".cython.score-63 {background-color: #FFFF22;}\n",
       ".cython.score-64 {background-color: #FFFF22;}\n",
       ".cython.score-65 {background-color: #FFFF22;}\n",
       ".cython.score-66 {background-color: #FFFF21;}\n",
       ".cython.score-67 {background-color: #FFFF21;}\n",
       ".cython.score-68 {background-color: #FFFF20;}\n",
       ".cython.score-69 {background-color: #FFFF20;}\n",
       ".cython.score-70 {background-color: #FFFF1f;}\n",
       ".cython.score-71 {background-color: #FFFF1f;}\n",
       ".cython.score-72 {background-color: #FFFF1f;}\n",
       ".cython.score-73 {background-color: #FFFF1e;}\n",
       ".cython.score-74 {background-color: #FFFF1e;}\n",
       ".cython.score-75 {background-color: #FFFF1e;}\n",
       ".cython.score-76 {background-color: #FFFF1d;}\n",
       ".cython.score-77 {background-color: #FFFF1d;}\n",
       ".cython.score-78 {background-color: #FFFF1c;}\n",
       ".cython.score-79 {background-color: #FFFF1c;}\n",
       ".cython.score-80 {background-color: #FFFF1c;}\n",
       ".cython.score-81 {background-color: #FFFF1c;}\n",
       ".cython.score-82 {background-color: #FFFF1b;}\n",
       ".cython.score-83 {background-color: #FFFF1b;}\n",
       ".cython.score-84 {background-color: #FFFF1b;}\n",
       ".cython.score-85 {background-color: #FFFF1a;}\n",
       ".cython.score-86 {background-color: #FFFF1a;}\n",
       ".cython.score-87 {background-color: #FFFF1a;}\n",
       ".cython.score-88 {background-color: #FFFF1a;}\n",
       ".cython.score-89 {background-color: #FFFF19;}\n",
       ".cython.score-90 {background-color: #FFFF19;}\n",
       ".cython.score-91 {background-color: #FFFF19;}\n",
       ".cython.score-92 {background-color: #FFFF19;}\n",
       ".cython.score-93 {background-color: #FFFF18;}\n",
       ".cython.score-94 {background-color: #FFFF18;}\n",
       ".cython.score-95 {background-color: #FFFF18;}\n",
       ".cython.score-96 {background-color: #FFFF18;}\n",
       ".cython.score-97 {background-color: #FFFF17;}\n",
       ".cython.score-98 {background-color: #FFFF17;}\n",
       ".cython.score-99 {background-color: #FFFF17;}\n",
       ".cython.score-100 {background-color: #FFFF17;}\n",
       ".cython.score-101 {background-color: #FFFF16;}\n",
       ".cython.score-102 {background-color: #FFFF16;}\n",
       ".cython.score-103 {background-color: #FFFF16;}\n",
       ".cython.score-104 {background-color: #FFFF16;}\n",
       ".cython.score-105 {background-color: #FFFF16;}\n",
       ".cython.score-106 {background-color: #FFFF15;}\n",
       ".cython.score-107 {background-color: #FFFF15;}\n",
       ".cython.score-108 {background-color: #FFFF15;}\n",
       ".cython.score-109 {background-color: #FFFF15;}\n",
       ".cython.score-110 {background-color: #FFFF15;}\n",
       ".cython.score-111 {background-color: #FFFF15;}\n",
       ".cython.score-112 {background-color: #FFFF14;}\n",
       ".cython.score-113 {background-color: #FFFF14;}\n",
       ".cython.score-114 {background-color: #FFFF14;}\n",
       ".cython.score-115 {background-color: #FFFF14;}\n",
       ".cython.score-116 {background-color: #FFFF14;}\n",
       ".cython.score-117 {background-color: #FFFF14;}\n",
       ".cython.score-118 {background-color: #FFFF13;}\n",
       ".cython.score-119 {background-color: #FFFF13;}\n",
       ".cython.score-120 {background-color: #FFFF13;}\n",
       ".cython.score-121 {background-color: #FFFF13;}\n",
       ".cython.score-122 {background-color: #FFFF13;}\n",
       ".cython.score-123 {background-color: #FFFF13;}\n",
       ".cython.score-124 {background-color: #FFFF13;}\n",
       ".cython.score-125 {background-color: #FFFF12;}\n",
       ".cython.score-126 {background-color: #FFFF12;}\n",
       ".cython.score-127 {background-color: #FFFF12;}\n",
       ".cython.score-128 {background-color: #FFFF12;}\n",
       ".cython.score-129 {background-color: #FFFF12;}\n",
       ".cython.score-130 {background-color: #FFFF12;}\n",
       ".cython.score-131 {background-color: #FFFF12;}\n",
       ".cython.score-132 {background-color: #FFFF11;}\n",
       ".cython.score-133 {background-color: #FFFF11;}\n",
       ".cython.score-134 {background-color: #FFFF11;}\n",
       ".cython.score-135 {background-color: #FFFF11;}\n",
       ".cython.score-136 {background-color: #FFFF11;}\n",
       ".cython.score-137 {background-color: #FFFF11;}\n",
       ".cython.score-138 {background-color: #FFFF11;}\n",
       ".cython.score-139 {background-color: #FFFF11;}\n",
       ".cython.score-140 {background-color: #FFFF11;}\n",
       ".cython.score-141 {background-color: #FFFF10;}\n",
       ".cython.score-142 {background-color: #FFFF10;}\n",
       ".cython.score-143 {background-color: #FFFF10;}\n",
       ".cython.score-144 {background-color: #FFFF10;}\n",
       ".cython.score-145 {background-color: #FFFF10;}\n",
       ".cython.score-146 {background-color: #FFFF10;}\n",
       ".cython.score-147 {background-color: #FFFF10;}\n",
       ".cython.score-148 {background-color: #FFFF10;}\n",
       ".cython.score-149 {background-color: #FFFF10;}\n",
       ".cython.score-150 {background-color: #FFFF0f;}\n",
       ".cython.score-151 {background-color: #FFFF0f;}\n",
       ".cython.score-152 {background-color: #FFFF0f;}\n",
       ".cython.score-153 {background-color: #FFFF0f;}\n",
       ".cython.score-154 {background-color: #FFFF0f;}\n",
       ".cython.score-155 {background-color: #FFFF0f;}\n",
       ".cython.score-156 {background-color: #FFFF0f;}\n",
       ".cython.score-157 {background-color: #FFFF0f;}\n",
       ".cython.score-158 {background-color: #FFFF0f;}\n",
       ".cython.score-159 {background-color: #FFFF0f;}\n",
       ".cython.score-160 {background-color: #FFFF0f;}\n",
       ".cython.score-161 {background-color: #FFFF0e;}\n",
       ".cython.score-162 {background-color: #FFFF0e;}\n",
       ".cython.score-163 {background-color: #FFFF0e;}\n",
       ".cython.score-164 {background-color: #FFFF0e;}\n",
       ".cython.score-165 {background-color: #FFFF0e;}\n",
       ".cython.score-166 {background-color: #FFFF0e;}\n",
       ".cython.score-167 {background-color: #FFFF0e;}\n",
       ".cython.score-168 {background-color: #FFFF0e;}\n",
       ".cython.score-169 {background-color: #FFFF0e;}\n",
       ".cython.score-170 {background-color: #FFFF0e;}\n",
       ".cython.score-171 {background-color: #FFFF0e;}\n",
       ".cython.score-172 {background-color: #FFFF0e;}\n",
       ".cython.score-173 {background-color: #FFFF0d;}\n",
       ".cython.score-174 {background-color: #FFFF0d;}\n",
       ".cython.score-175 {background-color: #FFFF0d;}\n",
       ".cython.score-176 {background-color: #FFFF0d;}\n",
       ".cython.score-177 {background-color: #FFFF0d;}\n",
       ".cython.score-178 {background-color: #FFFF0d;}\n",
       ".cython.score-179 {background-color: #FFFF0d;}\n",
       ".cython.score-180 {background-color: #FFFF0d;}\n",
       ".cython.score-181 {background-color: #FFFF0d;}\n",
       ".cython.score-182 {background-color: #FFFF0d;}\n",
       ".cython.score-183 {background-color: #FFFF0d;}\n",
       ".cython.score-184 {background-color: #FFFF0d;}\n",
       ".cython.score-185 {background-color: #FFFF0d;}\n",
       ".cython.score-186 {background-color: #FFFF0d;}\n",
       ".cython.score-187 {background-color: #FFFF0c;}\n",
       ".cython.score-188 {background-color: #FFFF0c;}\n",
       ".cython.score-189 {background-color: #FFFF0c;}\n",
       ".cython.score-190 {background-color: #FFFF0c;}\n",
       ".cython.score-191 {background-color: #FFFF0c;}\n",
       ".cython.score-192 {background-color: #FFFF0c;}\n",
       ".cython.score-193 {background-color: #FFFF0c;}\n",
       ".cython.score-194 {background-color: #FFFF0c;}\n",
       ".cython.score-195 {background-color: #FFFF0c;}\n",
       ".cython.score-196 {background-color: #FFFF0c;}\n",
       ".cython.score-197 {background-color: #FFFF0c;}\n",
       ".cython.score-198 {background-color: #FFFF0c;}\n",
       ".cython.score-199 {background-color: #FFFF0c;}\n",
       ".cython.score-200 {background-color: #FFFF0c;}\n",
       ".cython.score-201 {background-color: #FFFF0c;}\n",
       ".cython.score-202 {background-color: #FFFF0c;}\n",
       ".cython.score-203 {background-color: #FFFF0b;}\n",
       ".cython.score-204 {background-color: #FFFF0b;}\n",
       ".cython.score-205 {background-color: #FFFF0b;}\n",
       ".cython.score-206 {background-color: #FFFF0b;}\n",
       ".cython.score-207 {background-color: #FFFF0b;}\n",
       ".cython.score-208 {background-color: #FFFF0b;}\n",
       ".cython.score-209 {background-color: #FFFF0b;}\n",
       ".cython.score-210 {background-color: #FFFF0b;}\n",
       ".cython.score-211 {background-color: #FFFF0b;}\n",
       ".cython.score-212 {background-color: #FFFF0b;}\n",
       ".cython.score-213 {background-color: #FFFF0b;}\n",
       ".cython.score-214 {background-color: #FFFF0b;}\n",
       ".cython.score-215 {background-color: #FFFF0b;}\n",
       ".cython.score-216 {background-color: #FFFF0b;}\n",
       ".cython.score-217 {background-color: #FFFF0b;}\n",
       ".cython.score-218 {background-color: #FFFF0b;}\n",
       ".cython.score-219 {background-color: #FFFF0b;}\n",
       ".cython.score-220 {background-color: #FFFF0b;}\n",
       ".cython.score-221 {background-color: #FFFF0b;}\n",
       ".cython.score-222 {background-color: #FFFF0a;}\n",
       ".cython.score-223 {background-color: #FFFF0a;}\n",
       ".cython.score-224 {background-color: #FFFF0a;}\n",
       ".cython.score-225 {background-color: #FFFF0a;}\n",
       ".cython.score-226 {background-color: #FFFF0a;}\n",
       ".cython.score-227 {background-color: #FFFF0a;}\n",
       ".cython.score-228 {background-color: #FFFF0a;}\n",
       ".cython.score-229 {background-color: #FFFF0a;}\n",
       ".cython.score-230 {background-color: #FFFF0a;}\n",
       ".cython.score-231 {background-color: #FFFF0a;}\n",
       ".cython.score-232 {background-color: #FFFF0a;}\n",
       ".cython.score-233 {background-color: #FFFF0a;}\n",
       ".cython.score-234 {background-color: #FFFF0a;}\n",
       ".cython.score-235 {background-color: #FFFF0a;}\n",
       ".cython.score-236 {background-color: #FFFF0a;}\n",
       ".cython.score-237 {background-color: #FFFF0a;}\n",
       ".cython.score-238 {background-color: #FFFF0a;}\n",
       ".cython.score-239 {background-color: #FFFF0a;}\n",
       ".cython.score-240 {background-color: #FFFF0a;}\n",
       ".cython.score-241 {background-color: #FFFF0a;}\n",
       ".cython.score-242 {background-color: #FFFF0a;}\n",
       ".cython.score-243 {background-color: #FFFF0a;}\n",
       ".cython.score-244 {background-color: #FFFF0a;}\n",
       ".cython.score-245 {background-color: #FFFF0a;}\n",
       ".cython.score-246 {background-color: #FFFF09;}\n",
       ".cython.score-247 {background-color: #FFFF09;}\n",
       ".cython.score-248 {background-color: #FFFF09;}\n",
       ".cython.score-249 {background-color: #FFFF09;}\n",
       ".cython.score-250 {background-color: #FFFF09;}\n",
       ".cython.score-251 {background-color: #FFFF09;}\n",
       ".cython.score-252 {background-color: #FFFF09;}\n",
       ".cython.score-253 {background-color: #FFFF09;}\n",
       ".cython.score-254 {background-color: #FFFF09;}\n",
       "pre { line-height: 125%; }\n",
       "td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       ".cython .hll { background-color: #ffffcc }\n",
       ".cython { background: #f8f8f8; }\n",
       ".cython .c { color: #408080; font-style: italic } /* Comment */\n",
       ".cython .err { border: 1px solid #FF0000 } /* Error */\n",
       ".cython .k { color: #008000; font-weight: bold } /* Keyword */\n",
       ".cython .o { color: #666666 } /* Operator */\n",
       ".cython .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
       ".cython .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
       ".cython .cp { color: #BC7A00 } /* Comment.Preproc */\n",
       ".cython .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
       ".cython .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
       ".cython .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
       ".cython .gd { color: #A00000 } /* Generic.Deleted */\n",
       ".cython .ge { font-style: italic } /* Generic.Emph */\n",
       ".cython .gr { color: #FF0000 } /* Generic.Error */\n",
       ".cython .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
       ".cython .gi { color: #00A000 } /* Generic.Inserted */\n",
       ".cython .go { color: #888888 } /* Generic.Output */\n",
       ".cython .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
       ".cython .gs { font-weight: bold } /* Generic.Strong */\n",
       ".cython .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
       ".cython .gt { color: #0044DD } /* Generic.Traceback */\n",
       ".cython .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
       ".cython .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
       ".cython .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
       ".cython .kp { color: #008000 } /* Keyword.Pseudo */\n",
       ".cython .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
       ".cython .kt { color: #B00040 } /* Keyword.Type */\n",
       ".cython .m { color: #666666 } /* Literal.Number */\n",
       ".cython .s { color: #BA2121 } /* Literal.String */\n",
       ".cython .na { color: #7D9029 } /* Name.Attribute */\n",
       ".cython .nb { color: #008000 } /* Name.Builtin */\n",
       ".cython .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
       ".cython .no { color: #880000 } /* Name.Constant */\n",
       ".cython .nd { color: #AA22FF } /* Name.Decorator */\n",
       ".cython .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
       ".cython .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
       ".cython .nf { color: #0000FF } /* Name.Function */\n",
       ".cython .nl { color: #A0A000 } /* Name.Label */\n",
       ".cython .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
       ".cython .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
       ".cython .nv { color: #19177C } /* Name.Variable */\n",
       ".cython .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
       ".cython .w { color: #bbbbbb } /* Text.Whitespace */\n",
       ".cython .mb { color: #666666 } /* Literal.Number.Bin */\n",
       ".cython .mf { color: #666666 } /* Literal.Number.Float */\n",
       ".cython .mh { color: #666666 } /* Literal.Number.Hex */\n",
       ".cython .mi { color: #666666 } /* Literal.Number.Integer */\n",
       ".cython .mo { color: #666666 } /* Literal.Number.Oct */\n",
       ".cython .sa { color: #BA2121 } /* Literal.String.Affix */\n",
       ".cython .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
       ".cython .sc { color: #BA2121 } /* Literal.String.Char */\n",
       ".cython .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
       ".cython .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
       ".cython .s2 { color: #BA2121 } /* Literal.String.Double */\n",
       ".cython .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
       ".cython .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
       ".cython .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
       ".cython .sx { color: #008000 } /* Literal.String.Other */\n",
       ".cython .sr { color: #BB6688 } /* Literal.String.Regex */\n",
       ".cython .s1 { color: #BA2121 } /* Literal.String.Single */\n",
       ".cython .ss { color: #19177C } /* Literal.String.Symbol */\n",
       ".cython .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
       ".cython .fm { color: #0000FF } /* Name.Function.Magic */\n",
       ".cython .vc { color: #19177C } /* Name.Variable.Class */\n",
       ".cython .vg { color: #19177C } /* Name.Variable.Global */\n",
       ".cython .vi { color: #19177C } /* Name.Variable.Instance */\n",
       ".cython .vm { color: #19177C } /* Name.Variable.Magic */\n",
       ".cython .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
       "    </style>\n",
       "</head>\n",
       "<body class=\"cython\">\n",
       "<p><span style=\"border-bottom: solid 1px grey;\">Generated by Cython 0.29.24</span></p>\n",
       "<p>\n",
       "    <span style=\"background-color: #FFFF00\">Yellow lines</span> hint at Python interaction.<br />\n",
       "    Click on a line that starts with a \"<code>+</code>\" to see the C code that Cython generated for it.\n",
       "</p>\n",
       "<div class=\"cython\"><pre class=\"cython line score-0\">&#xA0;<span class=\"\">1</span>: <span class=\"k\">from</span> <span class=\"nn\">libc.stdlib</span> <span class=\"k\">cimport</span> <span class=\"n\">rand</span></pre>\n",
       "<pre class=\"cython line score-0\">&#xA0;<span class=\"\">2</span>: <span class=\"k\">cdef</span> <span class=\"kr\">extern</span> <span class=\"k\">from</span> <span class=\"s\">&#39;limits.h&#39;</span><span class=\"p\">:</span></pre>\n",
       "<pre class=\"cython line score-0\">&#xA0;<span class=\"\">3</span>:     <span class=\"nb\">int</span> <span class=\"n\">INT_MAX</span></pre>\n",
       "<pre class=\"cython line score-23\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">4</span>: <span class=\"k\">def</span> <span class=\"nf\">average_cy2</span><span class=\"p\">(</span><span class=\"nb\">int</span> <span class=\"n\">n</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-23 '>/* Python wrapper */\n",
       "static PyObject *__pyx_pw_46_cython_magic_8446b33ecac06df0a30f65b520a111dd_1average_cy2(PyObject *__pyx_self, PyObject *__pyx_arg_n); /*proto*/\n",
       "static PyMethodDef __pyx_mdef_46_cython_magic_8446b33ecac06df0a30f65b520a111dd_1average_cy2 = {\"average_cy2\", (PyCFunction)__pyx_pw_46_cython_magic_8446b33ecac06df0a30f65b520a111dd_1average_cy2, METH_O, 0};\n",
       "static PyObject *__pyx_pw_46_cython_magic_8446b33ecac06df0a30f65b520a111dd_1average_cy2(PyObject *__pyx_self, PyObject *__pyx_arg_n) {\n",
       "  int __pyx_v_n;\n",
       "  PyObject *__pyx_r = 0;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"average_cy2 (wrapper)\", 0);\n",
       "  assert(__pyx_arg_n); {\n",
       "    __pyx_v_n = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_arg_n); if (unlikely((__pyx_v_n == (int)-1) &amp;&amp; <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 4, __pyx_L3_error)</span>\n",
       "  }\n",
       "  goto __pyx_L4_argument_unpacking_done;\n",
       "  __pyx_L3_error:;\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_8446b33ecac06df0a30f65b520a111dd.average_cy2\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return NULL;\n",
       "  __pyx_L4_argument_unpacking_done:;\n",
       "  __pyx_r = __pyx_pf_46_cython_magic_8446b33ecac06df0a30f65b520a111dd_average_cy2(__pyx_self, ((int)__pyx_v_n));\n",
       "  int __pyx_lineno = 0;\n",
       "  const char *__pyx_filename = NULL;\n",
       "  int __pyx_clineno = 0;\n",
       "\n",
       "  /* function exit code */\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "\n",
       "static PyObject *__pyx_pf_46_cython_magic_8446b33ecac06df0a30f65b520a111dd_average_cy2(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {\n",
       "  CYTHON_UNUSED int __pyx_v_i;\n",
       "  float __pyx_v_s;\n",
       "  PyObject *__pyx_r = NULL;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"average_cy2\", 0);\n",
       "/* … */\n",
       "  /* function exit code */\n",
       "  __pyx_L1_error:;\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5);\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_8446b33ecac06df0a30f65b520a111dd.average_cy2\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  __pyx_r = NULL;\n",
       "  __pyx_L0:;\n",
       "  <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "/* … */\n",
       "  __pyx_tuple_ = <span class='py_c_api'>PyTuple_Pack</span>(4, __pyx_n_s_n, __pyx_n_s_n, __pyx_n_s_i, __pyx_n_s_s);<span class='error_goto'> if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 4, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple_);\n",
       "  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple_);\n",
       "/* … */\n",
       "  __pyx_t_1 = PyCFunction_NewEx(&amp;__pyx_mdef_46_cython_magic_8446b33ecac06df0a30f65b520a111dd_1average_cy2, NULL, __pyx_n_s_cython_magic_8446b33ecac06df0a3);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_average_cy2, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 4, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "</pre><pre class=\"cython line score-0\">&#xA0;<span class=\"\">5</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">int</span> <span class=\"nf\">i</span></pre>\n",
       "<pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">6</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">s</span> <span class=\"o\">=</span> <span class=\"mf\">0</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_s = 0.0;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">7</span>:     <span class=\"k\">for</span> <span class=\"n\">i</span> <span class=\"ow\">in</span> <span class=\"nb\">range</span><span class=\"p\">(</span><span class=\"n\">n</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_t_1 = __pyx_v_n;\n",
       "  __pyx_t_2 = __pyx_t_1;\n",
       "  for (__pyx_t_3 = 0; __pyx_t_3 &lt; __pyx_t_2; __pyx_t_3+=1) {\n",
       "    __pyx_v_i = __pyx_t_3;\n",
       "</pre><pre class=\"cython line score-5\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">8</span>:         <span class=\"n\">s</span> <span class=\"o\">+=</span> <span class=\"n\">rand</span><span class=\"p\">()</span> <span class=\"o\">/</span> <span class=\"n\">INT_MAX</span></pre>\n",
       "<pre class='cython code score-5 '>    __pyx_t_4 = rand();\n",
       "    if (unlikely(INT_MAX == 0)) {\n",
       "      <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "      <span class='error_goto'>__PYX_ERR(0, 8, __pyx_L1_error)</span>\n",
       "    }\n",
       "    __pyx_v_s = (__pyx_v_s + (((double)__pyx_t_4) / ((double)INT_MAX)));\n",
       "  }\n",
       "</pre><pre class=\"cython line score-11\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">9</span>:     <span class=\"k\">return</span> <span class=\"n\">s</span> <span class=\"o\">/</span> <span class=\"n\">n</span></pre>\n",
       "<pre class='cython code score-11 '>  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r);\n",
       "  if (unlikely(__pyx_v_n == 0)) {\n",
       "    <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "    <span class='error_goto'>__PYX_ERR(0, 9, __pyx_L1_error)</span>\n",
       "  }\n",
       "  __pyx_t_5 = <span class='py_c_api'>PyFloat_FromDouble</span>((__pyx_v_s / ((float)__pyx_v_n)));<span class='error_goto'> if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);\n",
       "  __pyx_r = __pyx_t_5;\n",
       "  __pyx_t_5 = 0;\n",
       "  goto __pyx_L0;\n",
       "</pre></div></body></html>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%cython -a\n",
    "from libc.stdlib cimport rand  \n",
    "cdef extern from 'limits.h':  \n",
    "    int INT_MAX  \n",
    "def average_cy2(int n):\n",
    "    cdef int i\n",
    "    cdef float s = 0\n",
    "    for i in range(n):\n",
    "        s += rand() / INT_MAX  \n",
    "    return s / n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 49.9 ms, sys: 448 µs, total: 50.3 ms\n",
      "Wall time: 50.2 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.500017523765564"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time average_cy2(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "49.4 ms ± 1.63 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit average_cy2(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Prime Numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pure Python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "def is_prime(I):\n",
    "    if I % 2 == 0: return False  \n",
    "    for i in range(3, int(I ** 0.5) + 1, 2):  \n",
    "        if I % i == 0: return False  \n",
    "    return True  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100000003"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n = int(1e8 + 3)  \n",
    "n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 20 µs, sys: 0 ns, total: 20 µs\n",
      "Wall time: 21.9 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100000007"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p1 = int(1e8 + 7)  \n",
    "p1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 274 µs, sys: 0 ns, total: 274 µs\n",
      "Wall time: 276 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime(p1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "p2 = 100109100129162907  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "57"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p2.bit_length()  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 15.5 s, sys: 25.9 ms, total: 15.5 s\n",
      "Wall time: 15.6 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime(p2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Numba"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "is_prime_nb = numba.jit(is_prime)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 77.9 ms, sys: 1.95 ms, total: 79.9 ms\n",
      "Wall time: 78.9 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime_nb(n)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 6 µs, sys: 0 ns, total: 6 µs\n",
      "Wall time: 7.87 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime_nb(n)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 24 µs, sys: 0 ns, total: 24 µs\n",
      "Wall time: 27.2 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime_nb(p1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1.31 s, sys: 4.36 ms, total: 1.31 s\n",
      "Wall time: 1.31 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime_nb(p2)  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cython"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%cython\n",
    "def is_prime_cy1(I):\n",
    "    if I % 2 == 0: return False\n",
    "    for i in range(3, int(I ** 0.5) + 1, 2):\n",
    "        if I % i == 0: return False\n",
    "    return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "382 µs ± 14.4 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit is_prime(p1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "204 µs ± 7.16 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit is_prime_cy1(p1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%cython\n",
    "def is_prime_cy2(long I):  \n",
    "    cdef long i  \n",
    "    if I % 2 == 0: return False\n",
    "    for i in range(3, int(I ** 0.5) + 1, 2):\n",
    "        if I % i == 0: return False\n",
    "    return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "41.3 µs ± 806 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit is_prime_cy2(p1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1.37 s, sys: 6.92 ms, total: 1.37 s\n",
      "Wall time: 1.37 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime_nb(p2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1.35 s, sys: 11.1 ms, total: 1.36 s\n",
      "Wall time: 1.37 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time is_prime_cy2(p2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Multiprocessing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "import multiprocessing as mp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "pool = mp.Pool(processes=4)  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b style=\"color: red;\">This currently does not work on Mac M1 machines.</b>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 2.7 ms, sys: 4.46 ms, total: 7.16 ms\n",
      "Wall time: 7.62 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[True, True, True, True, True, True, True, True, True, True]"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time pool.map(is_prime, 10 * [p1])  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 8.82 ms, sys: 4.18 ms, total: 13 ms\n",
      "Wall time: 4.83 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[True, True, True, True, True, True, True, True, True, True]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time pool.map(is_prime_nb, 10 * [p2])  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 4.11 ms, sys: 1.81 ms, total: 5.92 ms\n",
      "Wall time: 4.37 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[True, True, True, True, True, True, True, True, True, True]"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time pool.map(is_prime_cy2, 10 * [p2])  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Fibonacci Numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Recursive Algorithm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "from numba import njit"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "def fib_rec_py1(n):\n",
    "    if n < 2:\n",
    "        return n\n",
    "    else:\n",
    "        return fib_rec_py1(n - 1) + fib_rec_py1(n - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 3.33 s, sys: 9.24 ms, total: 3.34 s\n",
      "Wall time: 3.34 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "9227465"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_rec_py1(35)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [],
   "source": [
    "@njit\n",
    "def fib_rec_nb(n):\n",
    "    if n < 2:\n",
    "        return n\n",
    "    else:\n",
    "        return fib_rec_nb(n - 1) + fib_rec_nb(n - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 158 ms, sys: 12.4 ms, total: 170 ms\n",
      "Wall time: 169 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "9227465"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_rec_nb(35)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 86.1 ms, sys: 598 µs, total: 86.7 ms\n",
      "Wall time: 86.6 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "9227465"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_rec_nb(35)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%cython\n",
    "def fib_rec_cy(int n):\n",
    "    if n < 2:\n",
    "        return n\n",
    "    else:\n",
    "        return fib_rec_cy(n - 1) + fib_rec_cy(n - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 782 ms, sys: 4.77 ms, total: 787 ms\n",
      "Wall time: 785 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "9227465"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_rec_cy(35)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "from functools import lru_cache as cache"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "@cache(maxsize=None)  \n",
    "def fib_rec_py2(n):\n",
    "    if n < 2:\n",
    "        return n\n",
    "    else:\n",
    "        return fib_rec_py2(n - 1) + fib_rec_py2(n - 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 17 µs, sys: 7 µs, total: 24 µs\n",
      "Wall time: 27.2 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "9227465"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_rec_py2(35)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 22 µs, sys: 9 µs, total: 31 µs\n",
      "Wall time: 34.1 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "23416728348467685"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_rec_py2(80)  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Iterative Algorithm "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "def fib_it_py(n):\n",
    "    x, y = 0, 1\n",
    "    for i in range(1, n + 1):\n",
    "        x, y = y, x + y\n",
    "    return x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 6 µs, sys: 1e+03 ns, total: 7 µs\n",
      "Wall time: 7.87 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "23416728348467685"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_it_py(80)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "fib_it_nb = numba.jit(fib_it_py)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 66.9 ms, sys: 3.31 ms, total: 70.2 ms\n",
      "Wall time: 69.7 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "23416728348467685"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_it_nb(80)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 4 µs, sys: 1e+03 ns, total: 5 µs\n",
      "Wall time: 7.15 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "23416728348467685"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_it_nb(80)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%cython\n",
    "def fib_it_cy1(int n):\n",
    "    cdef long i\n",
    "    cdef long x = 0, y = 1\n",
    "    for i in range(1, n + 1):\n",
    "        x, y = y, x + y\n",
    "    return x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 4 µs, sys: 0 ns, total: 4 µs\n",
      "Wall time: 8.11 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "23416728348467685"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time fib_it_cy1(80)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9969216677189303386214405760200\n",
      "CPU times: user 174 µs, sys: 77 µs, total: 251 µs\n",
      "Wall time: 210 µs\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "fn = fib_rec_py2(150)  \n",
    "print(fn)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "103"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fn.bit_length()  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6792540214324356296\n",
      "CPU times: user 145 µs, sys: 52 µs, total: 197 µs\n",
      "Wall time: 170 µs\n"
     ]
    }
   ],
   "source": [
    "%%time \n",
    "fn = fib_it_nb(150)  \n",
    "print(fn)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "63"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fn.bit_length()  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6792540214324356296\n",
      "CPU times: user 289 µs, sys: 362 µs, total: 651 µs\n",
      "Wall time: 352 µs\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "fn = fib_it_cy1(150)  \n",
    "print(fn)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "63"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fn.bit_length()  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%cython\n",
    "cdef extern from *:\n",
    "    ctypedef int int128 '__int128_t'  \n",
    "def fib_it_cy2(int n):\n",
    "    cdef int128 i  \n",
    "    cdef int128 x = 0, y = 1  \n",
    "    for i in range(1, n + 1):\n",
    "        x, y = y, x + y\n",
    "    return x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9969216677189303386214405760200\n",
      "CPU times: user 229 µs, sys: 104 µs, total: 333 µs\n",
      "Wall time: 306 µs\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "fn = fib_it_cy2(150)  \n",
    "print(fn)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "103"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fn.bit_length()  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Number Pi"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The code example is taken from [StackExchange](https://codereview.stackexchange.com/questions/69370/monte-carlo-pi-calculation)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "import numpy as np\n",
    "from pylab import mpl, plt\n",
    "plt.style.use('seaborn')\n",
    "mpl.rcParams['font.family'] = 'serif'\n",
    "%config InlineBackend.figure_format = 'svg'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [],
   "source": [
    "rn = [(random.random() * 2 - 1, random.random() * 2 - 1)\n",
    "      for _ in range(500)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.67932462, -0.76109983],\n",
       "       [-0.54300098,  0.27858929],\n",
       "       [ 0.35603236,  0.30075112],\n",
       "       [-0.643277  , -0.55189129],\n",
       "       [ 0.90374257, -0.82721362]])"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rn = np.array(rn)\n",
    "rn[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-1.1, 1.1)"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"411.598125pt\" version=\"1.1\" viewBox=\"0 0 442.645312 411.598125\" width=\"442.645312pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 411.598125 \n",
       "L 442.645312 411.598125 \n",
       "L 442.645312 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 44.845313 387.72 \n",
       "L 435.445312 387.72 \n",
       "L 435.445312 7.2 \n",
       "L 44.845313 7.2 \n",
       "z\n",
       "\" style=\"fill:#eaeaf2;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 62.599858 387.72 \n",
       "L 62.599858 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\"/>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- −1.00 -->\n",
       "      <defs>\n",
       "       <path d=\"M 10.59375 35.296875 \n",
       "L 73.1875 35.296875 \n",
       "L 73.1875 27.390625 \n",
       "L 10.59375 27.390625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-8722\"/>\n",
       "       <path d=\"M 14.203125 0 \n",
       "L 14.203125 5.171875 \n",
       "L 26.90625 5.171875 \n",
       "L 26.90625 65.828125 \n",
       "L 12.203125 56.296875 \n",
       "L 12.203125 62.703125 \n",
       "L 29.984375 74.21875 \n",
       "L 36.71875 74.21875 \n",
       "L 36.71875 5.171875 \n",
       "L 49.421875 5.171875 \n",
       "L 49.421875 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-49\"/>\n",
       "       <path d=\"M 9.421875 5.078125 \n",
       "Q 9.421875 7.8125 11.28125 9.71875 \n",
       "Q 13.140625 11.625 15.921875 11.625 \n",
       "Q 18.609375 11.625 20.5 9.71875 \n",
       "Q 22.40625 7.8125 22.40625 5.078125 \n",
       "Q 22.40625 2.390625 20.5 0.484375 \n",
       "Q 18.609375 -1.421875 15.921875 -1.421875 \n",
       "Q 13.140625 -1.421875 11.28125 0.453125 \n",
       "Q 9.421875 2.34375 9.421875 5.078125 \n",
       "z\n",
       "\" id=\"DejaVuSerif-46\"/>\n",
       "       <path d=\"M 31.78125 3.421875 \n",
       "Q 39.265625 3.421875 42.96875 11.625 \n",
       "Q 46.6875 19.828125 46.6875 36.375 \n",
       "Q 46.6875 52.984375 42.96875 61.1875 \n",
       "Q 39.265625 69.390625 31.78125 69.390625 \n",
       "Q 24.3125 69.390625 20.59375 61.1875 \n",
       "Q 16.890625 52.984375 16.890625 36.375 \n",
       "Q 16.890625 19.828125 20.59375 11.625 \n",
       "Q 24.3125 3.421875 31.78125 3.421875 \n",
       "z\n",
       "M 31.78125 -1.421875 \n",
       "Q 19.921875 -1.421875 13.25 8.53125 \n",
       "Q 6.59375 18.5 6.59375 36.375 \n",
       "Q 6.59375 54.296875 13.25 64.25 \n",
       "Q 19.921875 74.21875 31.78125 74.21875 \n",
       "Q 43.703125 74.21875 50.34375 64.25 \n",
       "Q 56.984375 54.296875 56.984375 36.375 \n",
       "Q 56.984375 18.5 50.34375 8.53125 \n",
       "Q 43.703125 -1.421875 31.78125 -1.421875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-48\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(47.277202 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-8722\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"242.822266\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 106.986222 387.72 \n",
       "L 106.986222 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\"/>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- −0.75 -->\n",
       "      <defs>\n",
       "       <path d=\"M 56.390625 67.921875 \n",
       "L 27.875 0 \n",
       "L 20.609375 0 \n",
       "L 47.796875 64.890625 \n",
       "L 14.109375 64.890625 \n",
       "L 14.109375 55.90625 \n",
       "L 8.40625 55.90625 \n",
       "L 8.40625 72.90625 \n",
       "L 56.390625 72.90625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-55\"/>\n",
       "       <path d=\"M 50.296875 72.90625 \n",
       "L 50.296875 64.890625 \n",
       "L 16.890625 64.890625 \n",
       "L 16.890625 44 \n",
       "Q 19.4375 45.75 22.828125 46.625 \n",
       "Q 26.21875 47.515625 30.421875 47.515625 \n",
       "Q 42.234375 47.515625 49.0625 40.96875 \n",
       "Q 55.90625 34.421875 55.90625 23.09375 \n",
       "Q 55.90625 11.53125 49 5.046875 \n",
       "Q 42.09375 -1.421875 29.59375 -1.421875 \n",
       "Q 24.5625 -1.421875 19.28125 -0.1875 \n",
       "Q 14.015625 1.03125 8.5 3.515625 \n",
       "L 8.5 17.671875 \n",
       "L 14.015625 17.671875 \n",
       "Q 14.453125 10.75 18.421875 7.078125 \n",
       "Q 22.40625 3.421875 29.59375 3.421875 \n",
       "Q 37.3125 3.421875 41.453125 8.5 \n",
       "Q 45.609375 13.578125 45.609375 23.09375 \n",
       "Q 45.609375 32.5625 41.484375 37.609375 \n",
       "Q 37.359375 42.671875 29.59375 42.671875 \n",
       "Q 25.203125 42.671875 21.84375 41.109375 \n",
       "Q 18.5 39.546875 15.921875 36.28125 \n",
       "L 11.71875 36.28125 \n",
       "L 11.71875 72.90625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-53\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(91.663565 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-8722\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"242.822266\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 151.372585 387.72 \n",
       "L 151.372585 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\"/>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- −0.50 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(136.049929 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-8722\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "       <use x=\"242.822266\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 195.758949 387.72 \n",
       "L 195.758949 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\"/>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- −0.25 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.796875 55.515625 \n",
       "L 7.328125 55.515625 \n",
       "L 7.328125 68.5 \n",
       "Q 12.546875 71.296875 17.84375 72.75 \n",
       "Q 23.140625 74.21875 28.21875 74.21875 \n",
       "Q 39.59375 74.21875 46.1875 68.703125 \n",
       "Q 52.78125 63.1875 52.78125 53.71875 \n",
       "Q 52.78125 43.015625 37.84375 28.125 \n",
       "Q 36.671875 27 36.078125 26.421875 \n",
       "L 17.671875 8.015625 \n",
       "L 48.09375 8.015625 \n",
       "L 48.09375 17 \n",
       "L 53.8125 17 \n",
       "L 53.8125 0 \n",
       "L 6.78125 0 \n",
       "L 6.78125 5.328125 \n",
       "L 28.90625 27.390625 \n",
       "Q 36.234375 34.71875 39.359375 40.84375 \n",
       "Q 42.484375 46.96875 42.484375 53.71875 \n",
       "Q 42.484375 61.078125 38.640625 65.234375 \n",
       "Q 34.8125 69.390625 28.078125 69.390625 \n",
       "Q 21.09375 69.390625 17.28125 65.921875 \n",
       "Q 13.484375 62.453125 12.796875 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-50\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(180.436293 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-8722\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"242.822266\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 240.145313 387.72 \n",
       "L 240.145313 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\"/>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 0.00 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(229.0125 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 284.531676 387.72 \n",
       "L 284.531676 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\"/>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 0.25 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(273.398864 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 328.91804 387.72 \n",
       "L 328.91804 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\"/>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.50 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(317.785227 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 373.304403 387.72 \n",
       "L 373.304403 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\"/>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 0.75 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(362.171591 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_9\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 417.690767 387.72 \n",
       "L 417.690767 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\"/>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 1.00 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(406.557955 402.318437)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 370.423636 \n",
       "L 435.445312 370.423636 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_20\"/>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- −1.00 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 374.222855)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-8722\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"242.822266\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 327.182727 \n",
       "L 435.445312 327.182727 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_22\"/>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- −0.75 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 330.981946)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-8722\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"242.822266\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_23\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 283.941818 \n",
       "L 435.445312 283.941818 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_24\"/>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- −0.50 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 287.741037)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-8722\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "       <use x=\"242.822266\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_25\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 240.700909 \n",
       "L 435.445312 240.700909 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_26\"/>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- −0.25 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 244.500128)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-8722\"/>\n",
       "       <use x=\"83.789062\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"147.412109\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"179.199219\" xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"242.822266\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_27\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 197.46 \n",
       "L 435.445312 197.46 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_28\"/>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 0.00 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(15.579688 201.259219)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_29\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 154.219091 \n",
       "L 435.445312 154.219091 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_30\"/>\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 0.25 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(15.579688 158.01831)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_31\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 110.978182 \n",
       "L 435.445312 110.978182 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_32\"/>\n",
       "     <g id=\"text_16\">\n",
       "      <!-- 0.50 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(15.579688 114.777401)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_8\">\n",
       "     <g id=\"line2d_33\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 67.737273 \n",
       "L 435.445312 67.737273 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_34\"/>\n",
       "     <g id=\"text_17\">\n",
       "      <!-- 0.75 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(15.579688 71.536491)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_9\">\n",
       "     <g id=\"line2d_35\">\n",
       "      <path clip-path=\"url(#pcbcad73c86)\" d=\"M 44.845313 24.496364 \n",
       "L 435.445312 24.496364 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_36\"/>\n",
       "     <g id=\"text_18\">\n",
       "      <!-- 1.00 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(15.579688 28.295582)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-46\"/>\n",
       "       <use x=\"95.410156\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"159.033203\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path clip-path=\"url(#pcbcad73c86)\" d=\"M 240.145313 370.423636 \n",
       "C 287.230917 370.423636 332.394357 352.199097 365.688907 319.76376 \n",
       "C 398.983458 287.328424 417.690767 243.330493 417.690767 197.46 \n",
       "C 417.690767 151.589507 398.983458 107.591576 365.688907 75.15624 \n",
       "C 332.394357 42.720903 287.230917 24.496364 240.145313 24.496364 \n",
       "C 193.059708 24.496364 147.896268 42.720903 114.601718 75.15624 \n",
       "C 81.307167 107.591576 62.599858 151.589507 62.599858 197.46 \n",
       "C 62.599858 243.330493 81.307167 287.328424 114.601718 319.76376 \n",
       "C 147.896268 352.199097 193.059708 370.423636 240.145313 370.423636 \n",
       "z\n",
       "\" style=\"fill:none;stroke:#008000;stroke-linejoin:miter;stroke-width:2;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path clip-path=\"url(#pcbcad73c86)\" d=\"M 62.599858 370.423636 \n",
       "L 417.690767 370.423636 \n",
       "L 417.690767 24.496364 \n",
       "L 62.599858 24.496364 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;opacity:0.3;stroke:#0000ff;stroke-linejoin:miter;stroke-width:0.3;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_37\">\n",
       "    <defs>\n",
       "     <path d=\"M 0 1.75 \n",
       "C 0.464105 1.75 0.909265 1.565609 1.237437 1.237437 \n",
       "C 1.565609 0.909265 1.75 0.464105 1.75 0 \n",
       "C 1.75 -0.464105 1.565609 -0.909265 1.237437 -1.237437 \n",
       "C 0.909265 -1.565609 0.464105 -1.75 0 -1.75 \n",
       "C -0.464105 -1.75 -0.909265 -1.565609 -1.237437 -1.237437 \n",
       "C -1.565609 -0.909265 -1.75 -0.464105 -1.75 0 \n",
       "C -1.75 0.464105 -1.565609 0.909265 -1.237437 1.237437 \n",
       "C -0.909265 1.565609 -0.464105 1.75 0 1.75 \n",
       "z\n",
       "\" id=\"mae74278f75\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#pcbcad73c86)\">\n",
       "     <use style=\"fill:#ff0000;\" x=\"360.756312\" xlink:href=\"#mae74278f75\" y=\"329.102595\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"143.737956\" xlink:href=\"#mae74278f75\" y=\"149.274183\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"303.35724\" xlink:href=\"#mae74278f75\" y=\"145.440993\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"125.934405\" xlink:href=\"#mae74278f75\" y=\"292.917124\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"400.600697\" xlink:href=\"#mae74278f75\" y=\"340.537875\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"277.108014\" xlink:href=\"#mae74278f75\" y=\"341.316597\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"197.126244\" xlink:href=\"#mae74278f75\" y=\"316.376704\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"171.495632\" xlink:href=\"#mae74278f75\" y=\"83.483437\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"278.470667\" xlink:href=\"#mae74278f75\" y=\"114.488275\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"89.792029\" xlink:href=\"#mae74278f75\" y=\"333.999565\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"172.863623\" xlink:href=\"#mae74278f75\" y=\"218.634851\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"196.639665\" xlink:href=\"#mae74278f75\" y=\"254.875176\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"347.217189\" xlink:href=\"#mae74278f75\" y=\"360.308628\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"222.664236\" xlink:href=\"#mae74278f75\" y=\"26.807242\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"338.304161\" xlink:href=\"#mae74278f75\" y=\"365.989326\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"77.195877\" xlink:href=\"#mae74278f75\" y=\"222.626931\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"209.917175\" xlink:href=\"#mae74278f75\" y=\"139.024907\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"125.413957\" xlink:href=\"#mae74278f75\" y=\"363.957429\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"294.404845\" xlink:href=\"#mae74278f75\" y=\"103.513452\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"93.152565\" xlink:href=\"#mae74278f75\" y=\"242.813013\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"182.728874\" xlink:href=\"#mae74278f75\" y=\"188.391043\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"374.979464\" xlink:href=\"#mae74278f75\" y=\"272.201398\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"117.778638\" xlink:href=\"#mae74278f75\" y=\"292.291015\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"335.026903\" xlink:href=\"#mae74278f75\" y=\"240.757537\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"360.161301\" xlink:href=\"#mae74278f75\" y=\"368.528206\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"336.462092\" xlink:href=\"#mae74278f75\" y=\"40.078249\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"192.476594\" xlink:href=\"#mae74278f75\" y=\"84.427187\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"262.642058\" xlink:href=\"#mae74278f75\" y=\"161.666074\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"258.220456\" xlink:href=\"#mae74278f75\" y=\"59.962614\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"301.351763\" xlink:href=\"#mae74278f75\" y=\"196.781686\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"237.902938\" xlink:href=\"#mae74278f75\" y=\"361.604613\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"340.646322\" xlink:href=\"#mae74278f75\" y=\"76.348684\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"249.856009\" xlink:href=\"#mae74278f75\" y=\"92.594365\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"136.426905\" xlink:href=\"#mae74278f75\" y=\"274.048644\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"292.858363\" xlink:href=\"#mae74278f75\" y=\"179.71499\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"367.672285\" xlink:href=\"#mae74278f75\" y=\"112.397061\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"227.228366\" xlink:href=\"#mae74278f75\" y=\"294.4167\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"274.303407\" xlink:href=\"#mae74278f75\" y=\"54.305255\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"157.269419\" xlink:href=\"#mae74278f75\" y=\"283.965821\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"224.443781\" xlink:href=\"#mae74278f75\" y=\"83.706034\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"336.581735\" xlink:href=\"#mae74278f75\" y=\"28.437518\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"81.16403\" xlink:href=\"#mae74278f75\" y=\"144.681539\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"246.432783\" xlink:href=\"#mae74278f75\" y=\"93.54327\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"255.808483\" xlink:href=\"#mae74278f75\" y=\"234.597565\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"169.347505\" xlink:href=\"#mae74278f75\" y=\"31.636677\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"361.885597\" xlink:href=\"#mae74278f75\" y=\"344.245532\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"126.534207\" xlink:href=\"#mae74278f75\" y=\"334.481557\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"89.876885\" xlink:href=\"#mae74278f75\" y=\"367.151073\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"247.366564\" xlink:href=\"#mae74278f75\" y=\"264.62174\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"415.389743\" xlink:href=\"#mae74278f75\" y=\"249.995158\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"126.602456\" xlink:href=\"#mae74278f75\" y=\"200.881185\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"109.555184\" xlink:href=\"#mae74278f75\" y=\"247.570747\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"194.990242\" xlink:href=\"#mae74278f75\" y=\"349.455417\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"250.803194\" xlink:href=\"#mae74278f75\" y=\"255.530925\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"227.73108\" xlink:href=\"#mae74278f75\" y=\"205.339142\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"374.626856\" xlink:href=\"#mae74278f75\" y=\"171.443367\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"73.02106\" xlink:href=\"#mae74278f75\" y=\"255.125492\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"207.268855\" xlink:href=\"#mae74278f75\" y=\"199.33489\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"280.771274\" xlink:href=\"#mae74278f75\" y=\"26.689689\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"141.522348\" xlink:href=\"#mae74278f75\" y=\"58.512441\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"383.591392\" xlink:href=\"#mae74278f75\" y=\"53.785823\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"136.366797\" xlink:href=\"#mae74278f75\" y=\"173.613733\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"270.480161\" xlink:href=\"#mae74278f75\" y=\"270.860811\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"167.745987\" xlink:href=\"#mae74278f75\" y=\"63.072278\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"313.392169\" xlink:href=\"#mae74278f75\" y=\"287.945293\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"93.085861\" xlink:href=\"#mae74278f75\" y=\"191.680165\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"341.77072\" xlink:href=\"#mae74278f75\" y=\"365.039081\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"76.36407\" xlink:href=\"#mae74278f75\" y=\"177.789447\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"384.037324\" xlink:href=\"#mae74278f75\" y=\"170.502631\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"372.236462\" xlink:href=\"#mae74278f75\" y=\"332.405812\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"406.502878\" xlink:href=\"#mae74278f75\" y=\"140.926178\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"253.792585\" xlink:href=\"#mae74278f75\" y=\"315.319393\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"102.14332\" xlink:href=\"#mae74278f75\" y=\"292.016025\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"74.41271\" xlink:href=\"#mae74278f75\" y=\"100.955599\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"168.507925\" xlink:href=\"#mae74278f75\" y=\"98.377961\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"116.322203\" xlink:href=\"#mae74278f75\" y=\"139.246792\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"126.038637\" xlink:href=\"#mae74278f75\" y=\"281.627208\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"78.585577\" xlink:href=\"#mae74278f75\" y=\"321.100495\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"68.961552\" xlink:href=\"#mae74278f75\" y=\"125.130038\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"332.505098\" xlink:href=\"#mae74278f75\" y=\"61.547659\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"306.795494\" xlink:href=\"#mae74278f75\" y=\"244.589229\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"87.018655\" xlink:href=\"#mae74278f75\" y=\"148.146283\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"115.548173\" xlink:href=\"#mae74278f75\" y=\"298.260129\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"98.7396\" xlink:href=\"#mae74278f75\" y=\"298.854606\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"384.833903\" xlink:href=\"#mae74278f75\" y=\"329.328103\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"169.07222\" xlink:href=\"#mae74278f75\" y=\"305.846794\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"203.925263\" xlink:href=\"#mae74278f75\" y=\"141.165285\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"74.827727\" xlink:href=\"#mae74278f75\" y=\"276.907926\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"355.975094\" xlink:href=\"#mae74278f75\" y=\"334.954796\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"283.362093\" xlink:href=\"#mae74278f75\" y=\"211.225922\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"149.081249\" xlink:href=\"#mae74278f75\" y=\"301.735036\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"408.380106\" xlink:href=\"#mae74278f75\" y=\"42.265785\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"243.544713\" xlink:href=\"#mae74278f75\" y=\"268.922914\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"212.220239\" xlink:href=\"#mae74278f75\" y=\"206.496681\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"123.174936\" xlink:href=\"#mae74278f75\" y=\"358.750265\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"296.817195\" xlink:href=\"#mae74278f75\" y=\"293.268718\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"227.682525\" xlink:href=\"#mae74278f75\" y=\"52.303869\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"85.172505\" xlink:href=\"#mae74278f75\" y=\"42.651061\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"86.340732\" xlink:href=\"#mae74278f75\" y=\"356.841578\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"123.292635\" xlink:href=\"#mae74278f75\" y=\"342.56878\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"113.404709\" xlink:href=\"#mae74278f75\" y=\"53.050632\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"353.065435\" xlink:href=\"#mae74278f75\" y=\"330.556809\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"267.544612\" xlink:href=\"#mae74278f75\" y=\"323.513594\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"123.345059\" xlink:href=\"#mae74278f75\" y=\"124.198888\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"185.352383\" xlink:href=\"#mae74278f75\" y=\"308.826637\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"155.209712\" xlink:href=\"#mae74278f75\" y=\"366.358654\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"77.855184\" xlink:href=\"#mae74278f75\" y=\"105.458717\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"69.55415\" xlink:href=\"#mae74278f75\" y=\"194.648188\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"377.892202\" xlink:href=\"#mae74278f75\" y=\"289.647258\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"413.233008\" xlink:href=\"#mae74278f75\" y=\"191.066287\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"134.535773\" xlink:href=\"#mae74278f75\" y=\"244.43857\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"136.027369\" xlink:href=\"#mae74278f75\" y=\"92.925176\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"374.621085\" xlink:href=\"#mae74278f75\" y=\"351.241132\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"207.885143\" xlink:href=\"#mae74278f75\" y=\"263.66857\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"73.705837\" xlink:href=\"#mae74278f75\" y=\"367.4014\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"142.816154\" xlink:href=\"#mae74278f75\" y=\"341.147949\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"147.158757\" xlink:href=\"#mae74278f75\" y=\"224.188069\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"78.911266\" xlink:href=\"#mae74278f75\" y=\"168.09876\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"265.17209\" xlink:href=\"#mae74278f75\" y=\"164.812703\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"186.256084\" xlink:href=\"#mae74278f75\" y=\"332.183147\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"106.580002\" xlink:href=\"#mae74278f75\" y=\"233.561308\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"209.533912\" xlink:href=\"#mae74278f75\" y=\"76.499261\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"127.160287\" xlink:href=\"#mae74278f75\" y=\"35.021526\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"109.019318\" xlink:href=\"#mae74278f75\" y=\"131.307249\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"319.271764\" xlink:href=\"#mae74278f75\" y=\"258.848849\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"278.977516\" xlink:href=\"#mae74278f75\" y=\"260.13611\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"281.648362\" xlink:href=\"#mae74278f75\" y=\"307.518916\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"273.386465\" xlink:href=\"#mae74278f75\" y=\"288.575246\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"89.284914\" xlink:href=\"#mae74278f75\" y=\"36.881292\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"417.041991\" xlink:href=\"#mae74278f75\" y=\"250.218214\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"300.788124\" xlink:href=\"#mae74278f75\" y=\"273.935535\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"316.839816\" xlink:href=\"#mae74278f75\" y=\"35.306439\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"387.01269\" xlink:href=\"#mae74278f75\" y=\"336.140453\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"177.414394\" xlink:href=\"#mae74278f75\" y=\"27.415821\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"121.664822\" xlink:href=\"#mae74278f75\" y=\"221.177079\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"381.364759\" xlink:href=\"#mae74278f75\" y=\"224.568952\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"384.091127\" xlink:href=\"#mae74278f75\" y=\"366.808599\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"183.935712\" xlink:href=\"#mae74278f75\" y=\"62.883179\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"131.789755\" xlink:href=\"#mae74278f75\" y=\"91.345168\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"124.92834\" xlink:href=\"#mae74278f75\" y=\"368.314794\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"228.976941\" xlink:href=\"#mae74278f75\" y=\"177.714125\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"330.525732\" xlink:href=\"#mae74278f75\" y=\"210.90218\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"240.988668\" xlink:href=\"#mae74278f75\" y=\"248.260249\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"399.982345\" xlink:href=\"#mae74278f75\" y=\"213.668861\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"403.554795\" xlink:href=\"#mae74278f75\" y=\"241.508982\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"390.51048\" xlink:href=\"#mae74278f75\" y=\"279.465815\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"378.026824\" xlink:href=\"#mae74278f75\" y=\"167.355514\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"108.761017\" xlink:href=\"#mae74278f75\" y=\"92.714954\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"339.813679\" xlink:href=\"#mae74278f75\" y=\"60.337068\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"85.954039\" xlink:href=\"#mae74278f75\" y=\"192.40604\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"380.559451\" xlink:href=\"#mae74278f75\" y=\"246.643129\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"233.983412\" xlink:href=\"#mae74278f75\" y=\"136.74556\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"244.668854\" xlink:href=\"#mae74278f75\" y=\"262.391866\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"223.317762\" xlink:href=\"#mae74278f75\" y=\"176.733024\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"360.81987\" xlink:href=\"#mae74278f75\" y=\"207.81568\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"385.079513\" xlink:href=\"#mae74278f75\" y=\"325.957547\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"122.026642\" xlink:href=\"#mae74278f75\" y=\"64.561031\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"64.612837\" xlink:href=\"#mae74278f75\" y=\"154.026509\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"173.755988\" xlink:href=\"#mae74278f75\" y=\"149.000092\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"187.204245\" xlink:href=\"#mae74278f75\" y=\"45.877268\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"375.097028\" xlink:href=\"#mae74278f75\" y=\"134.283319\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"154.773144\" xlink:href=\"#mae74278f75\" y=\"323.696661\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"182.765597\" xlink:href=\"#mae74278f75\" y=\"177.712112\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"107.605798\" xlink:href=\"#mae74278f75\" y=\"133.944686\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"269.085318\" xlink:href=\"#mae74278f75\" y=\"366.462129\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"386.370397\" xlink:href=\"#mae74278f75\" y=\"33.540955\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"283.134029\" xlink:href=\"#mae74278f75\" y=\"78.971932\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"116.651567\" xlink:href=\"#mae74278f75\" y=\"74.448164\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"277.230839\" xlink:href=\"#mae74278f75\" y=\"205.985988\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"303.389117\" xlink:href=\"#mae74278f75\" y=\"298.149314\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"219.452057\" xlink:href=\"#mae74278f75\" y=\"85.471\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"296.262478\" xlink:href=\"#mae74278f75\" y=\"327.190105\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"350.887808\" xlink:href=\"#mae74278f75\" y=\"330.542251\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"305.897437\" xlink:href=\"#mae74278f75\" y=\"363.46359\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"281.963134\" xlink:href=\"#mae74278f75\" y=\"225.791171\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"323.007018\" xlink:href=\"#mae74278f75\" y=\"353.309654\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"400.12277\" xlink:href=\"#mae74278f75\" y=\"210.982616\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"228.980605\" xlink:href=\"#mae74278f75\" y=\"94.876294\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"111.27069\" xlink:href=\"#mae74278f75\" y=\"59.363905\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"204.274743\" xlink:href=\"#mae74278f75\" y=\"204.619121\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"355.900812\" xlink:href=\"#mae74278f75\" y=\"249.227454\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"416.792908\" xlink:href=\"#mae74278f75\" y=\"323.42432\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"145.844635\" xlink:href=\"#mae74278f75\" y=\"332.151035\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"102.491372\" xlink:href=\"#mae74278f75\" y=\"116.411413\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"380.410253\" xlink:href=\"#mae74278f75\" y=\"229.972062\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"136.860516\" xlink:href=\"#mae74278f75\" y=\"314.198319\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"165.883084\" xlink:href=\"#mae74278f75\" y=\"40.081516\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"414.32114\" xlink:href=\"#mae74278f75\" y=\"242.486977\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"348.498168\" xlink:href=\"#mae74278f75\" y=\"45.569503\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"203.546938\" xlink:href=\"#mae74278f75\" y=\"160.522535\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"340.602705\" xlink:href=\"#mae74278f75\" y=\"131.960564\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"74.701593\" xlink:href=\"#mae74278f75\" y=\"55.692437\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"393.765051\" xlink:href=\"#mae74278f75\" y=\"356.16216\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"271.098805\" xlink:href=\"#mae74278f75\" y=\"128.274504\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"398.42512\" xlink:href=\"#mae74278f75\" y=\"94.925829\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"410.114927\" xlink:href=\"#mae74278f75\" y=\"203.36467\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"258.137219\" xlink:href=\"#mae74278f75\" y=\"277.944195\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"380.072406\" xlink:href=\"#mae74278f75\" y=\"132.758843\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"351.885963\" xlink:href=\"#mae74278f75\" y=\"85.711023\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"280.914742\" xlink:href=\"#mae74278f75\" y=\"87.273272\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"63.903999\" xlink:href=\"#mae74278f75\" y=\"202.795249\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"332.111488\" xlink:href=\"#mae74278f75\" y=\"303.618368\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"210.413991\" xlink:href=\"#mae74278f75\" y=\"316.869873\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"337.907581\" xlink:href=\"#mae74278f75\" y=\"118.03759\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"116.464733\" xlink:href=\"#mae74278f75\" y=\"94.876798\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"395.806691\" xlink:href=\"#mae74278f75\" y=\"255.628811\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"207.135897\" xlink:href=\"#mae74278f75\" y=\"326.992314\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"311.58768\" xlink:href=\"#mae74278f75\" y=\"353.402331\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"131.854987\" xlink:href=\"#mae74278f75\" y=\"257.164862\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"150.379412\" xlink:href=\"#mae74278f75\" y=\"228.272753\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"167.959123\" xlink:href=\"#mae74278f75\" y=\"112.345157\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"374.618312\" xlink:href=\"#mae74278f75\" y=\"232.932191\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"246.621402\" xlink:href=\"#mae74278f75\" y=\"28.386987\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"217.631863\" xlink:href=\"#mae74278f75\" y=\"222.26097\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"281.943825\" xlink:href=\"#mae74278f75\" y=\"74.356433\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"363.093291\" xlink:href=\"#mae74278f75\" y=\"138.847196\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"332.189442\" xlink:href=\"#mae74278f75\" y=\"213.312972\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"277.357291\" xlink:href=\"#mae74278f75\" y=\"302.246261\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"396.304597\" xlink:href=\"#mae74278f75\" y=\"45.152312\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"271.38098\" xlink:href=\"#mae74278f75\" y=\"77.088634\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"73.203371\" xlink:href=\"#mae74278f75\" y=\"222.253211\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"398.016951\" xlink:href=\"#mae74278f75\" y=\"126.08278\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"212.698554\" xlink:href=\"#mae74278f75\" y=\"227.724204\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"305.075482\" xlink:href=\"#mae74278f75\" y=\"137.562171\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"231.270498\" xlink:href=\"#mae74278f75\" y=\"354.364489\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"301.269096\" xlink:href=\"#mae74278f75\" y=\"66.805078\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"152.062522\" xlink:href=\"#mae74278f75\" y=\"290.584591\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"398.447737\" xlink:href=\"#mae74278f75\" y=\"191.831387\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"149.309605\" xlink:href=\"#mae74278f75\" y=\"277.507041\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"223.02085\" xlink:href=\"#mae74278f75\" y=\"223.311189\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"233.894695\" xlink:href=\"#mae74278f75\" y=\"333.996312\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"63.163806\" xlink:href=\"#mae74278f75\" y=\"276.458996\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"96.947896\" xlink:href=\"#mae74278f75\" y=\"154.517563\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"122.844977\" xlink:href=\"#mae74278f75\" y=\"184.876079\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"366.673461\" xlink:href=\"#mae74278f75\" y=\"171.312064\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"156.810782\" xlink:href=\"#mae74278f75\" y=\"172.281862\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"79.606399\" xlink:href=\"#mae74278f75\" y=\"305.054128\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"83.587937\" xlink:href=\"#mae74278f75\" y=\"35.251748\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"65.655678\" xlink:href=\"#mae74278f75\" y=\"304.185394\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"223.714669\" xlink:href=\"#mae74278f75\" y=\"74.426027\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"165.269254\" xlink:href=\"#mae74278f75\" y=\"224.564227\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"140.94098\" xlink:href=\"#mae74278f75\" y=\"292.189328\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"313.323251\" xlink:href=\"#mae74278f75\" y=\"234.309664\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"146.226811\" xlink:href=\"#mae74278f75\" y=\"147.21956\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"330.290284\" xlink:href=\"#mae74278f75\" y=\"243.579072\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"363.144219\" xlink:href=\"#mae74278f75\" y=\"96.429559\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"275.872387\" xlink:href=\"#mae74278f75\" y=\"92.481535\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"406.867838\" xlink:href=\"#mae74278f75\" y=\"124.579758\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"103.54389\" xlink:href=\"#mae74278f75\" y=\"47.708078\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"170.483367\" xlink:href=\"#mae74278f75\" y=\"59.119795\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"294.502997\" xlink:href=\"#mae74278f75\" y=\"327.538129\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"92.598764\" xlink:href=\"#mae74278f75\" y=\"153.385486\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"206.735046\" xlink:href=\"#mae74278f75\" y=\"336.782377\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"414.920235\" xlink:href=\"#mae74278f75\" y=\"158.431791\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"331.866907\" xlink:href=\"#mae74278f75\" y=\"191.450626\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"173.392117\" xlink:href=\"#mae74278f75\" y=\"292.76963\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"197.419322\" xlink:href=\"#mae74278f75\" y=\"110.430808\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"364.827574\" xlink:href=\"#mae74278f75\" y=\"308.338864\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"249.035749\" xlink:href=\"#mae74278f75\" y=\"104.314062\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"132.633571\" xlink:href=\"#mae74278f75\" y=\"63.795979\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"63.849405\" xlink:href=\"#mae74278f75\" y=\"289.364999\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"417.480981\" xlink:href=\"#mae74278f75\" y=\"96.323469\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"413.120674\" xlink:href=\"#mae74278f75\" y=\"26.769522\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"361.428462\" xlink:href=\"#mae74278f75\" y=\"74.440384\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"306.421007\" xlink:href=\"#mae74278f75\" y=\"37.210563\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"110.513082\" xlink:href=\"#mae74278f75\" y=\"98.729492\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"247.434273\" xlink:href=\"#mae74278f75\" y=\"313.555979\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"208.052272\" xlink:href=\"#mae74278f75\" y=\"107.637247\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"150.74707\" xlink:href=\"#mae74278f75\" y=\"32.352624\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"186.671416\" xlink:href=\"#mae74278f75\" y=\"65.960124\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"322.62896\" xlink:href=\"#mae74278f75\" y=\"262.971319\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"67.286987\" xlink:href=\"#mae74278f75\" y=\"334.01239\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"235.008925\" xlink:href=\"#mae74278f75\" y=\"111.987941\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"171.180898\" xlink:href=\"#mae74278f75\" y=\"150.377339\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"407.064934\" xlink:href=\"#mae74278f75\" y=\"43.484646\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"167.249912\" xlink:href=\"#mae74278f75\" y=\"76.985208\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"279.732156\" xlink:href=\"#mae74278f75\" y=\"47.312879\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"182.327885\" xlink:href=\"#mae74278f75\" y=\"336.754799\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"389.313302\" xlink:href=\"#mae74278f75\" y=\"237.043516\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"272.350506\" xlink:href=\"#mae74278f75\" y=\"312.443361\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"203.934985\" xlink:href=\"#mae74278f75\" y=\"351.470036\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"219.204089\" xlink:href=\"#mae74278f75\" y=\"276.729588\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"241.98885\" xlink:href=\"#mae74278f75\" y=\"44.675084\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"127.22931\" xlink:href=\"#mae74278f75\" y=\"265.004134\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"268.878662\" xlink:href=\"#mae74278f75\" y=\"318.15368\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"340.395328\" xlink:href=\"#mae74278f75\" y=\"247.348735\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"90.056431\" xlink:href=\"#mae74278f75\" y=\"67.356631\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"356.356053\" xlink:href=\"#mae74278f75\" y=\"336.805726\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"399.4351\" xlink:href=\"#mae74278f75\" y=\"250.273406\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"73.839515\" xlink:href=\"#mae74278f75\" y=\"195.757763\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"176.732194\" xlink:href=\"#mae74278f75\" y=\"239.24378\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"214.75671\" xlink:href=\"#mae74278f75\" y=\"310.85998\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"399.620683\" xlink:href=\"#mae74278f75\" y=\"137.390419\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"76.462419\" xlink:href=\"#mae74278f75\" y=\"26.792407\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"349.392595\" xlink:href=\"#mae74278f75\" y=\"103.006799\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"281.344449\" xlink:href=\"#mae74278f75\" y=\"262.479648\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"226.831381\" xlink:href=\"#mae74278f75\" y=\"148.060644\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"128.216242\" xlink:href=\"#mae74278f75\" y=\"307.216679\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"310.544412\" xlink:href=\"#mae74278f75\" y=\"141.746208\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"271.841011\" xlink:href=\"#mae74278f75\" y=\"125.853672\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"72.303573\" xlink:href=\"#mae74278f75\" y=\"339.629196\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"308.027863\" xlink:href=\"#mae74278f75\" y=\"38.810065\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"160.878299\" xlink:href=\"#mae74278f75\" y=\"311.996764\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"254.860202\" xlink:href=\"#mae74278f75\" y=\"237.090125\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"235.113267\" xlink:href=\"#mae74278f75\" y=\"322.176144\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"316.278456\" xlink:href=\"#mae74278f75\" y=\"321.532662\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"239.718285\" xlink:href=\"#mae74278f75\" y=\"267.214293\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"91.69509\" xlink:href=\"#mae74278f75\" y=\"81.652911\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"204.651383\" xlink:href=\"#mae74278f75\" y=\"245.269737\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"194.14814\" xlink:href=\"#mae74278f75\" y=\"52.506127\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"251.03247\" xlink:href=\"#mae74278f75\" y=\"227.117666\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"81.76508\" xlink:href=\"#mae74278f75\" y=\"332.655038\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"369.89143\" xlink:href=\"#mae74278f75\" y=\"236.918207\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"269.400183\" xlink:href=\"#mae74278f75\" y=\"224.665525\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"385.933667\" xlink:href=\"#mae74278f75\" y=\"192.085349\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"380.299955\" xlink:href=\"#mae74278f75\" y=\"291.154981\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"364.229322\" xlink:href=\"#mae74278f75\" y=\"336.621308\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"370.262554\" xlink:href=\"#mae74278f75\" y=\"307.163706\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"106.099088\" xlink:href=\"#mae74278f75\" y=\"141.14491\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"364.019628\" xlink:href=\"#mae74278f75\" y=\"251.071849\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"370.420071\" xlink:href=\"#mae74278f75\" y=\"268.629544\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"124.808286\" xlink:href=\"#mae74278f75\" y=\"155.938889\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"358.810632\" xlink:href=\"#mae74278f75\" y=\"199.898023\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"144.050723\" xlink:href=\"#mae74278f75\" y=\"83.066818\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"391.777965\" xlink:href=\"#mae74278f75\" y=\"90.919691\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"301.173231\" xlink:href=\"#mae74278f75\" y=\"169.380175\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"87.224942\" xlink:href=\"#mae74278f75\" y=\"71.25933\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"339.751057\" xlink:href=\"#mae74278f75\" y=\"24.688266\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"337.867863\" xlink:href=\"#mae74278f75\" y=\"334.353317\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"184.891402\" xlink:href=\"#mae74278f75\" y=\"312.394273\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"250.428108\" xlink:href=\"#mae74278f75\" y=\"229.462318\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"222.772004\" xlink:href=\"#mae74278f75\" y=\"152.899989\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"95.933538\" xlink:href=\"#mae74278f75\" y=\"103.888175\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"240.184579\" xlink:href=\"#mae74278f75\" y=\"155.201241\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"274.793736\" xlink:href=\"#mae74278f75\" y=\"147.536632\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"142.43434\" xlink:href=\"#mae74278f75\" y=\"363.830987\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"311.823944\" xlink:href=\"#mae74278f75\" y=\"93.355828\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"349.254033\" xlink:href=\"#mae74278f75\" y=\"168.054348\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"114.590737\" xlink:href=\"#mae74278f75\" y=\"194.390242\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"297.191782\" xlink:href=\"#mae74278f75\" y=\"107.964165\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"121.246733\" xlink:href=\"#mae74278f75\" y=\"44.153804\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"294.665014\" xlink:href=\"#mae74278f75\" y=\"285.025144\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"155.020082\" xlink:href=\"#mae74278f75\" y=\"145.52165\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"271.049431\" xlink:href=\"#mae74278f75\" y=\"290.054439\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"175.828184\" xlink:href=\"#mae74278f75\" y=\"338.407691\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"152.844247\" xlink:href=\"#mae74278f75\" y=\"164.190996\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"409.744123\" xlink:href=\"#mae74278f75\" y=\"286.808898\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"170.987947\" xlink:href=\"#mae74278f75\" y=\"314.97214\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"400.745171\" xlink:href=\"#mae74278f75\" y=\"95.648287\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"397.856988\" xlink:href=\"#mae74278f75\" y=\"121.725048\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"366.050343\" xlink:href=\"#mae74278f75\" y=\"294.634319\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"109.230348\" xlink:href=\"#mae74278f75\" y=\"311.300556\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"87.333089\" xlink:href=\"#mae74278f75\" y=\"222.82503\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"415.872482\" xlink:href=\"#mae74278f75\" y=\"312.475188\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"402.836329\" xlink:href=\"#mae74278f75\" y=\"89.557615\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"147.363506\" xlink:href=\"#mae74278f75\" y=\"240.645577\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"193.814093\" xlink:href=\"#mae74278f75\" y=\"27.98116\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"393.740811\" xlink:href=\"#mae74278f75\" y=\"142.406384\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"187.607904\" xlink:href=\"#mae74278f75\" y=\"365.096991\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"252.503164\" xlink:href=\"#mae74278f75\" y=\"91.002091\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"409.483064\" xlink:href=\"#mae74278f75\" y=\"304.963589\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"230.723447\" xlink:href=\"#mae74278f75\" y=\"321.361024\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"76.861301\" xlink:href=\"#mae74278f75\" y=\"38.334189\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"73.832327\" xlink:href=\"#mae74278f75\" y=\"337.094343\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"247.082478\" xlink:href=\"#mae74278f75\" y=\"27.263406\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"135.530017\" xlink:href=\"#mae74278f75\" y=\"152.236717\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"145.222173\" xlink:href=\"#mae74278f75\" y=\"89.280157\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"96.981261\" xlink:href=\"#mae74278f75\" y=\"191.021818\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"216.814742\" xlink:href=\"#mae74278f75\" y=\"29.481673\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"359.595104\" xlink:href=\"#mae74278f75\" y=\"94.182833\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"322.540693\" xlink:href=\"#mae74278f75\" y=\"290.251447\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"238.071864\" xlink:href=\"#mae74278f75\" y=\"156.507411\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"122.444351\" xlink:href=\"#mae74278f75\" y=\"274.649207\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"319.486522\" xlink:href=\"#mae74278f75\" y=\"135.833799\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"93.892311\" xlink:href=\"#mae74278f75\" y=\"25.883365\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"226.581085\" xlink:href=\"#mae74278f75\" y=\"326.376122\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"172.563393\" xlink:href=\"#mae74278f75\" y=\"181.207602\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"130.485742\" xlink:href=\"#mae74278f75\" y=\"369.634149\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"391.239086\" xlink:href=\"#mae74278f75\" y=\"347.759792\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"159.719798\" xlink:href=\"#mae74278f75\" y=\"36.691344\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"320.562497\" xlink:href=\"#mae74278f75\" y=\"224.529136\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"121.803008\" xlink:href=\"#mae74278f75\" y=\"337.495147\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"86.08825\" xlink:href=\"#mae74278f75\" y=\"179.26511\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"307.666759\" xlink:href=\"#mae74278f75\" y=\"149.754776\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"326.232653\" xlink:href=\"#mae74278f75\" y=\"359.461114\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"353.88694\" xlink:href=\"#mae74278f75\" y=\"251.745239\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"317.113761\" xlink:href=\"#mae74278f75\" y=\"336.205933\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"230.015103\" xlink:href=\"#mae74278f75\" y=\"82.816484\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"211.77483\" xlink:href=\"#mae74278f75\" y=\"184.872682\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"89.554826\" xlink:href=\"#mae74278f75\" y=\"173.838352\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"148.478982\" xlink:href=\"#mae74278f75\" y=\"318.637047\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"358.244522\" xlink:href=\"#mae74278f75\" y=\"185.353895\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"348.230437\" xlink:href=\"#mae74278f75\" y=\"68.061994\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"224.065126\" xlink:href=\"#mae74278f75\" y=\"261.160238\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"182.10672\" xlink:href=\"#mae74278f75\" y=\"88.288444\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"322.988032\" xlink:href=\"#mae74278f75\" y=\"198.826203\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"321.473574\" xlink:href=\"#mae74278f75\" y=\"369.677038\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"79.333656\" xlink:href=\"#mae74278f75\" y=\"127.189215\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"323.067491\" xlink:href=\"#mae74278f75\" y=\"283.322528\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"246.758945\" xlink:href=\"#mae74278f75\" y=\"62.822217\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"111.530912\" xlink:href=\"#mae74278f75\" y=\"220.139447\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"408.095597\" xlink:href=\"#mae74278f75\" y=\"265.21757\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"274.820089\" xlink:href=\"#mae74278f75\" y=\"109.519118\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"372.329152\" xlink:href=\"#mae74278f75\" y=\"227.921102\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"248.454137\" xlink:href=\"#mae74278f75\" y=\"313.302426\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"74.403471\" xlink:href=\"#mae74278f75\" y=\"163.724965\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"75.398905\" xlink:href=\"#mae74278f75\" y=\"293.695141\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"271.372164\" xlink:href=\"#mae74278f75\" y=\"156.58942\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"324.289649\" xlink:href=\"#mae74278f75\" y=\"106.518675\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"77.120599\" xlink:href=\"#mae74278f75\" y=\"271.276757\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"177.06469\" xlink:href=\"#mae74278f75\" y=\"59.280499\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"216.402735\" xlink:href=\"#mae74278f75\" y=\"360.034998\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"397.575419\" xlink:href=\"#mae74278f75\" y=\"65.219993\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"367.470253\" xlink:href=\"#mae74278f75\" y=\"302.877829\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"328.115525\" xlink:href=\"#mae74278f75\" y=\"100.48096\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"416.829317\" xlink:href=\"#mae74278f75\" y=\"276.254291\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"112.67968\" xlink:href=\"#mae74278f75\" y=\"112.67342\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"198.928939\" xlink:href=\"#mae74278f75\" y=\"133.13029\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"311.19871\" xlink:href=\"#mae74278f75\" y=\"323.101935\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"164.862993\" xlink:href=\"#mae74278f75\" y=\"321.617483\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"138.272823\" xlink:href=\"#mae74278f75\" y=\"213.999817\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"272.166635\" xlink:href=\"#mae74278f75\" y=\"174.500621\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"353.892979\" xlink:href=\"#mae74278f75\" y=\"212.833328\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"139.734059\" xlink:href=\"#mae74278f75\" y=\"25.227325\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"364.116097\" xlink:href=\"#mae74278f75\" y=\"70.40761\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"269.8472\" xlink:href=\"#mae74278f75\" y=\"214.050009\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"275.776495\" xlink:href=\"#mae74278f75\" y=\"201.544874\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"64.015022\" xlink:href=\"#mae74278f75\" y=\"208.806015\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"344.271909\" xlink:href=\"#mae74278f75\" y=\"90.451242\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"206.31496\" xlink:href=\"#mae74278f75\" y=\"302.512228\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"190.287\" xlink:href=\"#mae74278f75\" y=\"316.181471\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"308.883174\" xlink:href=\"#mae74278f75\" y=\"186.767364\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"385.409307\" xlink:href=\"#mae74278f75\" y=\"253.660288\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"290.109872\" xlink:href=\"#mae74278f75\" y=\"173.230787\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"206.450105\" xlink:href=\"#mae74278f75\" y=\"239.560576\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"267.521583\" xlink:href=\"#mae74278f75\" y=\"298.808238\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"278.085829\" xlink:href=\"#mae74278f75\" y=\"55.82266\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"385.396093\" xlink:href=\"#mae74278f75\" y=\"180.649768\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"302.096832\" xlink:href=\"#mae74278f75\" y=\"205.071285\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"318.592129\" xlink:href=\"#mae74278f75\" y=\"222.51213\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"178.971217\" xlink:href=\"#mae74278f75\" y=\"107.777784\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"239.224128\" xlink:href=\"#mae74278f75\" y=\"244.946246\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"278.577499\" xlink:href=\"#mae74278f75\" y=\"45.034333\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"321.681008\" xlink:href=\"#mae74278f75\" y=\"215.227619\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"384.093156\" xlink:href=\"#mae74278f75\" y=\"68.69425\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"69.085377\" xlink:href=\"#mae74278f75\" y=\"173.584372\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"267.396518\" xlink:href=\"#mae74278f75\" y=\"37.376668\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"128.427978\" xlink:href=\"#mae74278f75\" y=\"137.951223\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"113.020337\" xlink:href=\"#mae74278f75\" y=\"354.196964\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"128.888756\" xlink:href=\"#mae74278f75\" y=\"365.554085\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"241.689536\" xlink:href=\"#mae74278f75\" y=\"108.043695\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"189.63342\" xlink:href=\"#mae74278f75\" y=\"206.436936\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"290.481976\" xlink:href=\"#mae74278f75\" y=\"311.268169\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"289.969035\" xlink:href=\"#mae74278f75\" y=\"191.239926\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"92.419006\" xlink:href=\"#mae74278f75\" y=\"370.14683\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"340.188773\" xlink:href=\"#mae74278f75\" y=\"257.636766\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"326.274194\" xlink:href=\"#mae74278f75\" y=\"314.462053\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"184.377049\" xlink:href=\"#mae74278f75\" y=\"55.380278\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"258.239741\" xlink:href=\"#mae74278f75\" y=\"275.703765\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"139.79536\" xlink:href=\"#mae74278f75\" y=\"313.813257\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"166.932347\" xlink:href=\"#mae74278f75\" y=\"212.530518\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"185.438735\" xlink:href=\"#mae74278f75\" y=\"63.067078\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"92.474445\" xlink:href=\"#mae74278f75\" y=\"312.495695\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"166.779236\" xlink:href=\"#mae74278f75\" y=\"192.406611\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"268.466916\" xlink:href=\"#mae74278f75\" y=\"37.08625\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"103.348458\" xlink:href=\"#mae74278f75\" y=\"153.791158\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"310.826129\" xlink:href=\"#mae74278f75\" y=\"90.484738\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"68.381704\" xlink:href=\"#mae74278f75\" y=\"126.574577\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"211.933238\" xlink:href=\"#mae74278f75\" y=\"218.56877\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"296.693583\" xlink:href=\"#mae74278f75\" y=\"24.682931\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"389.863553\" xlink:href=\"#mae74278f75\" y=\"32.959788\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"173.293916\" xlink:href=\"#mae74278f75\" y=\"268.200935\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"407.073568\" xlink:href=\"#mae74278f75\" y=\"96.586931\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"202.736494\" xlink:href=\"#mae74278f75\" y=\"258.186345\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"150.871306\" xlink:href=\"#mae74278f75\" y=\"316.930281\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"63.948314\" xlink:href=\"#mae74278f75\" y=\"324.156291\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"264.252882\" xlink:href=\"#mae74278f75\" y=\"192.127564\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"194.984211\" xlink:href=\"#mae74278f75\" y=\"275.95576\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"378.933967\" xlink:href=\"#mae74278f75\" y=\"145.873862\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"319.444023\" xlink:href=\"#mae74278f75\" y=\"214.44385\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"304.492711\" xlink:href=\"#mae74278f75\" y=\"299.431752\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"243.386408\" xlink:href=\"#mae74278f75\" y=\"30.636036\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"222.903856\" xlink:href=\"#mae74278f75\" y=\"324.756268\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"369.030764\" xlink:href=\"#mae74278f75\" y=\"109.519672\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"173.823199\" xlink:href=\"#mae74278f75\" y=\"111.169875\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"314.498715\" xlink:href=\"#mae74278f75\" y=\"160.590501\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"128.67431\" xlink:href=\"#mae74278f75\" y=\"313.764236\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"415.237733\" xlink:href=\"#mae74278f75\" y=\"258.666594\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"161.42121\" xlink:href=\"#mae74278f75\" y=\"46.068188\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"219.948607\" xlink:href=\"#mae74278f75\" y=\"36.302576\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"176.189513\" xlink:href=\"#mae74278f75\" y=\"168.695899\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"94.897764\" xlink:href=\"#mae74278f75\" y=\"279.766224\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"265.986079\" xlink:href=\"#mae74278f75\" y=\"177.853786\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"348.117191\" xlink:href=\"#mae74278f75\" y=\"200.643366\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"215.821895\" xlink:href=\"#mae74278f75\" y=\"142.492338\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"298.776613\" xlink:href=\"#mae74278f75\" y=\"302.722267\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"76.200082\" xlink:href=\"#mae74278f75\" y=\"111.585637\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"350.824793\" xlink:href=\"#mae74278f75\" y=\"205.450058\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"222.419895\" xlink:href=\"#mae74278f75\" y=\"67.237126\"/>\n",
       "     <use style=\"fill:#ff0000;\" x=\"95.466101\" xlink:href=\"#mae74278f75\" y=\"282.623835\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 44.845313 387.72 \n",
       "L 44.845313 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 435.445312 387.72 \n",
       "L 435.445312 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_7\">\n",
       "    <path d=\"M 44.845312 387.72 \n",
       "L 435.445313 387.72 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_8\">\n",
       "    <path d=\"M 44.845312 7.2 \n",
       "L 435.445313 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pcbcad73c86\">\n",
       "   <rect height=\"380.52\" width=\"390.6\" x=\"44.845313\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 504x504 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(7, 7))\n",
    "ax = fig.add_subplot(1, 1, 1)\n",
    "circ = plt.Circle((0, 0), radius=1, edgecolor='g', lw=2.0,\n",
    "                  facecolor='None')  \n",
    "box = plt.Rectangle((-1, -1), 2, 2, edgecolor='b', alpha=0.3)  \n",
    "ax.add_patch(circ)  \n",
    "ax.add_patch(box)  \n",
    "plt.plot(rn[:, 0], rn[:, 1], 'r.')  \n",
    "plt.ylim(-1.1, 1.1)\n",
    "plt.xlim(-1.1, 1.1)\n",
    "# plt.savefig('../../images/ch10/perf_01.png');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [],
   "source": [
    "n = int(1e7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 177 ms, sys: 47.6 ms, total: 225 ms\n",
      "Wall time: 224 ms\n"
     ]
    }
   ],
   "source": [
    "%time rn = np.random.random((n, 2)) * 2 - 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "160000000"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rn.nbytes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 215 ms, sys: 87 ms, total: 302 ms\n",
      "Wall time: 301 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([0.904, 1.202, 0.602, 1.146, 0.845, 0.56 , 1.017, 0.267])"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time distance = np.sqrt((rn ** 2).sum(axis=1))  \n",
    "distance[:8].round(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 13.8 ms, sys: 5.19 ms, total: 19 ms\n",
      "Wall time: 17.2 ms\n"
     ]
    }
   ],
   "source": [
    "%time frac = (distance <= 1.0).sum() / len(distance)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.1416932"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pi_mcs = frac * 4  \n",
    "pi_mcs  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mcs_pi_py(n):\n",
    "    circle = 0\n",
    "    for _ in range(n):\n",
    "        x, y = random.random(), random.random()\n",
    "        if (x ** 2 + y ** 2) ** 0.5 <= 1:\n",
    "            circle += 1\n",
    "    return (4 * circle) / n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 4.55 s, sys: 16.1 ms, total: 4.57 s\n",
      "Wall time: 4.58 s\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "3.1419796"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time mcs_pi_py(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [],
   "source": [
    "mcs_pi_nb = numba.jit(mcs_pi_py)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 325 ms, sys: 6.39 ms, total: 331 ms\n",
      "Wall time: 334 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "3.1412564"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time mcs_pi_nb(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 116 ms, sys: 771 µs, total: 117 ms\n",
      "Wall time: 116 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "3.1414516"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time mcs_pi_nb(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<!-- Generated by Cython 0.29.24 -->\n",
       "<html>\n",
       "<head>\n",
       "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n",
       "    <title>Cython: _cython_magic_92ae563c1590716bb0c3b88eca8f9fd0.pyx</title>\n",
       "    <style type=\"text/css\">\n",
       "    \n",
       "body.cython { font-family: courier; font-size: 12; }\n",
       "\n",
       ".cython.tag  {  }\n",
       ".cython.line { margin: 0em }\n",
       ".cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; }\n",
       "\n",
       ".cython.line .run { background-color: #B0FFB0; }\n",
       ".cython.line .mis { background-color: #FFB0B0; }\n",
       ".cython.code.run  { border-left: 8px solid #B0FFB0; }\n",
       ".cython.code.mis  { border-left: 8px solid #FFB0B0; }\n",
       "\n",
       ".cython.code .py_c_api  { color: red; }\n",
       ".cython.code .py_macro_api  { color: #FF7000; }\n",
       ".cython.code .pyx_c_api  { color: #FF3000; }\n",
       ".cython.code .pyx_macro_api  { color: #FF7000; }\n",
       ".cython.code .refnanny  { color: #FFA000; }\n",
       ".cython.code .trace  { color: #FFA000; }\n",
       ".cython.code .error_goto  { color: #FFA000; }\n",
       "\n",
       ".cython.code .coerce  { color: #008000; border: 1px dotted #008000 }\n",
       ".cython.code .py_attr { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_attr  { color: #0000FF; }\n",
       ".cython.code .py_call { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_call  { color: #0000FF; }\n",
       "\n",
       ".cython.score-0 {background-color: #FFFFff;}\n",
       ".cython.score-1 {background-color: #FFFFe7;}\n",
       ".cython.score-2 {background-color: #FFFFd4;}\n",
       ".cython.score-3 {background-color: #FFFFc4;}\n",
       ".cython.score-4 {background-color: #FFFFb6;}\n",
       ".cython.score-5 {background-color: #FFFFaa;}\n",
       ".cython.score-6 {background-color: #FFFF9f;}\n",
       ".cython.score-7 {background-color: #FFFF96;}\n",
       ".cython.score-8 {background-color: #FFFF8d;}\n",
       ".cython.score-9 {background-color: #FFFF86;}\n",
       ".cython.score-10 {background-color: #FFFF7f;}\n",
       ".cython.score-11 {background-color: #FFFF79;}\n",
       ".cython.score-12 {background-color: #FFFF73;}\n",
       ".cython.score-13 {background-color: #FFFF6e;}\n",
       ".cython.score-14 {background-color: #FFFF6a;}\n",
       ".cython.score-15 {background-color: #FFFF66;}\n",
       ".cython.score-16 {background-color: #FFFF62;}\n",
       ".cython.score-17 {background-color: #FFFF5e;}\n",
       ".cython.score-18 {background-color: #FFFF5b;}\n",
       ".cython.score-19 {background-color: #FFFF57;}\n",
       ".cython.score-20 {background-color: #FFFF55;}\n",
       ".cython.score-21 {background-color: #FFFF52;}\n",
       ".cython.score-22 {background-color: #FFFF4f;}\n",
       ".cython.score-23 {background-color: #FFFF4d;}\n",
       ".cython.score-24 {background-color: #FFFF4b;}\n",
       ".cython.score-25 {background-color: #FFFF48;}\n",
       ".cython.score-26 {background-color: #FFFF46;}\n",
       ".cython.score-27 {background-color: #FFFF44;}\n",
       ".cython.score-28 {background-color: #FFFF43;}\n",
       ".cython.score-29 {background-color: #FFFF41;}\n",
       ".cython.score-30 {background-color: #FFFF3f;}\n",
       ".cython.score-31 {background-color: #FFFF3e;}\n",
       ".cython.score-32 {background-color: #FFFF3c;}\n",
       ".cython.score-33 {background-color: #FFFF3b;}\n",
       ".cython.score-34 {background-color: #FFFF39;}\n",
       ".cython.score-35 {background-color: #FFFF38;}\n",
       ".cython.score-36 {background-color: #FFFF37;}\n",
       ".cython.score-37 {background-color: #FFFF36;}\n",
       ".cython.score-38 {background-color: #FFFF35;}\n",
       ".cython.score-39 {background-color: #FFFF34;}\n",
       ".cython.score-40 {background-color: #FFFF33;}\n",
       ".cython.score-41 {background-color: #FFFF32;}\n",
       ".cython.score-42 {background-color: #FFFF31;}\n",
       ".cython.score-43 {background-color: #FFFF30;}\n",
       ".cython.score-44 {background-color: #FFFF2f;}\n",
       ".cython.score-45 {background-color: #FFFF2e;}\n",
       ".cython.score-46 {background-color: #FFFF2d;}\n",
       ".cython.score-47 {background-color: #FFFF2c;}\n",
       ".cython.score-48 {background-color: #FFFF2b;}\n",
       ".cython.score-49 {background-color: #FFFF2b;}\n",
       ".cython.score-50 {background-color: #FFFF2a;}\n",
       ".cython.score-51 {background-color: #FFFF29;}\n",
       ".cython.score-52 {background-color: #FFFF29;}\n",
       ".cython.score-53 {background-color: #FFFF28;}\n",
       ".cython.score-54 {background-color: #FFFF27;}\n",
       ".cython.score-55 {background-color: #FFFF27;}\n",
       ".cython.score-56 {background-color: #FFFF26;}\n",
       ".cython.score-57 {background-color: #FFFF26;}\n",
       ".cython.score-58 {background-color: #FFFF25;}\n",
       ".cython.score-59 {background-color: #FFFF24;}\n",
       ".cython.score-60 {background-color: #FFFF24;}\n",
       ".cython.score-61 {background-color: #FFFF23;}\n",
       ".cython.score-62 {background-color: #FFFF23;}\n",
       ".cython.score-63 {background-color: #FFFF22;}\n",
       ".cython.score-64 {background-color: #FFFF22;}\n",
       ".cython.score-65 {background-color: #FFFF22;}\n",
       ".cython.score-66 {background-color: #FFFF21;}\n",
       ".cython.score-67 {background-color: #FFFF21;}\n",
       ".cython.score-68 {background-color: #FFFF20;}\n",
       ".cython.score-69 {background-color: #FFFF20;}\n",
       ".cython.score-70 {background-color: #FFFF1f;}\n",
       ".cython.score-71 {background-color: #FFFF1f;}\n",
       ".cython.score-72 {background-color: #FFFF1f;}\n",
       ".cython.score-73 {background-color: #FFFF1e;}\n",
       ".cython.score-74 {background-color: #FFFF1e;}\n",
       ".cython.score-75 {background-color: #FFFF1e;}\n",
       ".cython.score-76 {background-color: #FFFF1d;}\n",
       ".cython.score-77 {background-color: #FFFF1d;}\n",
       ".cython.score-78 {background-color: #FFFF1c;}\n",
       ".cython.score-79 {background-color: #FFFF1c;}\n",
       ".cython.score-80 {background-color: #FFFF1c;}\n",
       ".cython.score-81 {background-color: #FFFF1c;}\n",
       ".cython.score-82 {background-color: #FFFF1b;}\n",
       ".cython.score-83 {background-color: #FFFF1b;}\n",
       ".cython.score-84 {background-color: #FFFF1b;}\n",
       ".cython.score-85 {background-color: #FFFF1a;}\n",
       ".cython.score-86 {background-color: #FFFF1a;}\n",
       ".cython.score-87 {background-color: #FFFF1a;}\n",
       ".cython.score-88 {background-color: #FFFF1a;}\n",
       ".cython.score-89 {background-color: #FFFF19;}\n",
       ".cython.score-90 {background-color: #FFFF19;}\n",
       ".cython.score-91 {background-color: #FFFF19;}\n",
       ".cython.score-92 {background-color: #FFFF19;}\n",
       ".cython.score-93 {background-color: #FFFF18;}\n",
       ".cython.score-94 {background-color: #FFFF18;}\n",
       ".cython.score-95 {background-color: #FFFF18;}\n",
       ".cython.score-96 {background-color: #FFFF18;}\n",
       ".cython.score-97 {background-color: #FFFF17;}\n",
       ".cython.score-98 {background-color: #FFFF17;}\n",
       ".cython.score-99 {background-color: #FFFF17;}\n",
       ".cython.score-100 {background-color: #FFFF17;}\n",
       ".cython.score-101 {background-color: #FFFF16;}\n",
       ".cython.score-102 {background-color: #FFFF16;}\n",
       ".cython.score-103 {background-color: #FFFF16;}\n",
       ".cython.score-104 {background-color: #FFFF16;}\n",
       ".cython.score-105 {background-color: #FFFF16;}\n",
       ".cython.score-106 {background-color: #FFFF15;}\n",
       ".cython.score-107 {background-color: #FFFF15;}\n",
       ".cython.score-108 {background-color: #FFFF15;}\n",
       ".cython.score-109 {background-color: #FFFF15;}\n",
       ".cython.score-110 {background-color: #FFFF15;}\n",
       ".cython.score-111 {background-color: #FFFF15;}\n",
       ".cython.score-112 {background-color: #FFFF14;}\n",
       ".cython.score-113 {background-color: #FFFF14;}\n",
       ".cython.score-114 {background-color: #FFFF14;}\n",
       ".cython.score-115 {background-color: #FFFF14;}\n",
       ".cython.score-116 {background-color: #FFFF14;}\n",
       ".cython.score-117 {background-color: #FFFF14;}\n",
       ".cython.score-118 {background-color: #FFFF13;}\n",
       ".cython.score-119 {background-color: #FFFF13;}\n",
       ".cython.score-120 {background-color: #FFFF13;}\n",
       ".cython.score-121 {background-color: #FFFF13;}\n",
       ".cython.score-122 {background-color: #FFFF13;}\n",
       ".cython.score-123 {background-color: #FFFF13;}\n",
       ".cython.score-124 {background-color: #FFFF13;}\n",
       ".cython.score-125 {background-color: #FFFF12;}\n",
       ".cython.score-126 {background-color: #FFFF12;}\n",
       ".cython.score-127 {background-color: #FFFF12;}\n",
       ".cython.score-128 {background-color: #FFFF12;}\n",
       ".cython.score-129 {background-color: #FFFF12;}\n",
       ".cython.score-130 {background-color: #FFFF12;}\n",
       ".cython.score-131 {background-color: #FFFF12;}\n",
       ".cython.score-132 {background-color: #FFFF11;}\n",
       ".cython.score-133 {background-color: #FFFF11;}\n",
       ".cython.score-134 {background-color: #FFFF11;}\n",
       ".cython.score-135 {background-color: #FFFF11;}\n",
       ".cython.score-136 {background-color: #FFFF11;}\n",
       ".cython.score-137 {background-color: #FFFF11;}\n",
       ".cython.score-138 {background-color: #FFFF11;}\n",
       ".cython.score-139 {background-color: #FFFF11;}\n",
       ".cython.score-140 {background-color: #FFFF11;}\n",
       ".cython.score-141 {background-color: #FFFF10;}\n",
       ".cython.score-142 {background-color: #FFFF10;}\n",
       ".cython.score-143 {background-color: #FFFF10;}\n",
       ".cython.score-144 {background-color: #FFFF10;}\n",
       ".cython.score-145 {background-color: #FFFF10;}\n",
       ".cython.score-146 {background-color: #FFFF10;}\n",
       ".cython.score-147 {background-color: #FFFF10;}\n",
       ".cython.score-148 {background-color: #FFFF10;}\n",
       ".cython.score-149 {background-color: #FFFF10;}\n",
       ".cython.score-150 {background-color: #FFFF0f;}\n",
       ".cython.score-151 {background-color: #FFFF0f;}\n",
       ".cython.score-152 {background-color: #FFFF0f;}\n",
       ".cython.score-153 {background-color: #FFFF0f;}\n",
       ".cython.score-154 {background-color: #FFFF0f;}\n",
       ".cython.score-155 {background-color: #FFFF0f;}\n",
       ".cython.score-156 {background-color: #FFFF0f;}\n",
       ".cython.score-157 {background-color: #FFFF0f;}\n",
       ".cython.score-158 {background-color: #FFFF0f;}\n",
       ".cython.score-159 {background-color: #FFFF0f;}\n",
       ".cython.score-160 {background-color: #FFFF0f;}\n",
       ".cython.score-161 {background-color: #FFFF0e;}\n",
       ".cython.score-162 {background-color: #FFFF0e;}\n",
       ".cython.score-163 {background-color: #FFFF0e;}\n",
       ".cython.score-164 {background-color: #FFFF0e;}\n",
       ".cython.score-165 {background-color: #FFFF0e;}\n",
       ".cython.score-166 {background-color: #FFFF0e;}\n",
       ".cython.score-167 {background-color: #FFFF0e;}\n",
       ".cython.score-168 {background-color: #FFFF0e;}\n",
       ".cython.score-169 {background-color: #FFFF0e;}\n",
       ".cython.score-170 {background-color: #FFFF0e;}\n",
       ".cython.score-171 {background-color: #FFFF0e;}\n",
       ".cython.score-172 {background-color: #FFFF0e;}\n",
       ".cython.score-173 {background-color: #FFFF0d;}\n",
       ".cython.score-174 {background-color: #FFFF0d;}\n",
       ".cython.score-175 {background-color: #FFFF0d;}\n",
       ".cython.score-176 {background-color: #FFFF0d;}\n",
       ".cython.score-177 {background-color: #FFFF0d;}\n",
       ".cython.score-178 {background-color: #FFFF0d;}\n",
       ".cython.score-179 {background-color: #FFFF0d;}\n",
       ".cython.score-180 {background-color: #FFFF0d;}\n",
       ".cython.score-181 {background-color: #FFFF0d;}\n",
       ".cython.score-182 {background-color: #FFFF0d;}\n",
       ".cython.score-183 {background-color: #FFFF0d;}\n",
       ".cython.score-184 {background-color: #FFFF0d;}\n",
       ".cython.score-185 {background-color: #FFFF0d;}\n",
       ".cython.score-186 {background-color: #FFFF0d;}\n",
       ".cython.score-187 {background-color: #FFFF0c;}\n",
       ".cython.score-188 {background-color: #FFFF0c;}\n",
       ".cython.score-189 {background-color: #FFFF0c;}\n",
       ".cython.score-190 {background-color: #FFFF0c;}\n",
       ".cython.score-191 {background-color: #FFFF0c;}\n",
       ".cython.score-192 {background-color: #FFFF0c;}\n",
       ".cython.score-193 {background-color: #FFFF0c;}\n",
       ".cython.score-194 {background-color: #FFFF0c;}\n",
       ".cython.score-195 {background-color: #FFFF0c;}\n",
       ".cython.score-196 {background-color: #FFFF0c;}\n",
       ".cython.score-197 {background-color: #FFFF0c;}\n",
       ".cython.score-198 {background-color: #FFFF0c;}\n",
       ".cython.score-199 {background-color: #FFFF0c;}\n",
       ".cython.score-200 {background-color: #FFFF0c;}\n",
       ".cython.score-201 {background-color: #FFFF0c;}\n",
       ".cython.score-202 {background-color: #FFFF0c;}\n",
       ".cython.score-203 {background-color: #FFFF0b;}\n",
       ".cython.score-204 {background-color: #FFFF0b;}\n",
       ".cython.score-205 {background-color: #FFFF0b;}\n",
       ".cython.score-206 {background-color: #FFFF0b;}\n",
       ".cython.score-207 {background-color: #FFFF0b;}\n",
       ".cython.score-208 {background-color: #FFFF0b;}\n",
       ".cython.score-209 {background-color: #FFFF0b;}\n",
       ".cython.score-210 {background-color: #FFFF0b;}\n",
       ".cython.score-211 {background-color: #FFFF0b;}\n",
       ".cython.score-212 {background-color: #FFFF0b;}\n",
       ".cython.score-213 {background-color: #FFFF0b;}\n",
       ".cython.score-214 {background-color: #FFFF0b;}\n",
       ".cython.score-215 {background-color: #FFFF0b;}\n",
       ".cython.score-216 {background-color: #FFFF0b;}\n",
       ".cython.score-217 {background-color: #FFFF0b;}\n",
       ".cython.score-218 {background-color: #FFFF0b;}\n",
       ".cython.score-219 {background-color: #FFFF0b;}\n",
       ".cython.score-220 {background-color: #FFFF0b;}\n",
       ".cython.score-221 {background-color: #FFFF0b;}\n",
       ".cython.score-222 {background-color: #FFFF0a;}\n",
       ".cython.score-223 {background-color: #FFFF0a;}\n",
       ".cython.score-224 {background-color: #FFFF0a;}\n",
       ".cython.score-225 {background-color: #FFFF0a;}\n",
       ".cython.score-226 {background-color: #FFFF0a;}\n",
       ".cython.score-227 {background-color: #FFFF0a;}\n",
       ".cython.score-228 {background-color: #FFFF0a;}\n",
       ".cython.score-229 {background-color: #FFFF0a;}\n",
       ".cython.score-230 {background-color: #FFFF0a;}\n",
       ".cython.score-231 {background-color: #FFFF0a;}\n",
       ".cython.score-232 {background-color: #FFFF0a;}\n",
       ".cython.score-233 {background-color: #FFFF0a;}\n",
       ".cython.score-234 {background-color: #FFFF0a;}\n",
       ".cython.score-235 {background-color: #FFFF0a;}\n",
       ".cython.score-236 {background-color: #FFFF0a;}\n",
       ".cython.score-237 {background-color: #FFFF0a;}\n",
       ".cython.score-238 {background-color: #FFFF0a;}\n",
       ".cython.score-239 {background-color: #FFFF0a;}\n",
       ".cython.score-240 {background-color: #FFFF0a;}\n",
       ".cython.score-241 {background-color: #FFFF0a;}\n",
       ".cython.score-242 {background-color: #FFFF0a;}\n",
       ".cython.score-243 {background-color: #FFFF0a;}\n",
       ".cython.score-244 {background-color: #FFFF0a;}\n",
       ".cython.score-245 {background-color: #FFFF0a;}\n",
       ".cython.score-246 {background-color: #FFFF09;}\n",
       ".cython.score-247 {background-color: #FFFF09;}\n",
       ".cython.score-248 {background-color: #FFFF09;}\n",
       ".cython.score-249 {background-color: #FFFF09;}\n",
       ".cython.score-250 {background-color: #FFFF09;}\n",
       ".cython.score-251 {background-color: #FFFF09;}\n",
       ".cython.score-252 {background-color: #FFFF09;}\n",
       ".cython.score-253 {background-color: #FFFF09;}\n",
       ".cython.score-254 {background-color: #FFFF09;}\n",
       "pre { line-height: 125%; }\n",
       "td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       ".cython .hll { background-color: #ffffcc }\n",
       ".cython { background: #f8f8f8; }\n",
       ".cython .c { color: #408080; font-style: italic } /* Comment */\n",
       ".cython .err { border: 1px solid #FF0000 } /* Error */\n",
       ".cython .k { color: #008000; font-weight: bold } /* Keyword */\n",
       ".cython .o { color: #666666 } /* Operator */\n",
       ".cython .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
       ".cython .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
       ".cython .cp { color: #BC7A00 } /* Comment.Preproc */\n",
       ".cython .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
       ".cython .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
       ".cython .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
       ".cython .gd { color: #A00000 } /* Generic.Deleted */\n",
       ".cython .ge { font-style: italic } /* Generic.Emph */\n",
       ".cython .gr { color: #FF0000 } /* Generic.Error */\n",
       ".cython .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
       ".cython .gi { color: #00A000 } /* Generic.Inserted */\n",
       ".cython .go { color: #888888 } /* Generic.Output */\n",
       ".cython .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
       ".cython .gs { font-weight: bold } /* Generic.Strong */\n",
       ".cython .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
       ".cython .gt { color: #0044DD } /* Generic.Traceback */\n",
       ".cython .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
       ".cython .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
       ".cython .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
       ".cython .kp { color: #008000 } /* Keyword.Pseudo */\n",
       ".cython .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
       ".cython .kt { color: #B00040 } /* Keyword.Type */\n",
       ".cython .m { color: #666666 } /* Literal.Number */\n",
       ".cython .s { color: #BA2121 } /* Literal.String */\n",
       ".cython .na { color: #7D9029 } /* Name.Attribute */\n",
       ".cython .nb { color: #008000 } /* Name.Builtin */\n",
       ".cython .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
       ".cython .no { color: #880000 } /* Name.Constant */\n",
       ".cython .nd { color: #AA22FF } /* Name.Decorator */\n",
       ".cython .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
       ".cython .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
       ".cython .nf { color: #0000FF } /* Name.Function */\n",
       ".cython .nl { color: #A0A000 } /* Name.Label */\n",
       ".cython .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
       ".cython .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
       ".cython .nv { color: #19177C } /* Name.Variable */\n",
       ".cython .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
       ".cython .w { color: #bbbbbb } /* Text.Whitespace */\n",
       ".cython .mb { color: #666666 } /* Literal.Number.Bin */\n",
       ".cython .mf { color: #666666 } /* Literal.Number.Float */\n",
       ".cython .mh { color: #666666 } /* Literal.Number.Hex */\n",
       ".cython .mi { color: #666666 } /* Literal.Number.Integer */\n",
       ".cython .mo { color: #666666 } /* Literal.Number.Oct */\n",
       ".cython .sa { color: #BA2121 } /* Literal.String.Affix */\n",
       ".cython .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
       ".cython .sc { color: #BA2121 } /* Literal.String.Char */\n",
       ".cython .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
       ".cython .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
       ".cython .s2 { color: #BA2121 } /* Literal.String.Double */\n",
       ".cython .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
       ".cython .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
       ".cython .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
       ".cython .sx { color: #008000 } /* Literal.String.Other */\n",
       ".cython .sr { color: #BB6688 } /* Literal.String.Regex */\n",
       ".cython .s1 { color: #BA2121 } /* Literal.String.Single */\n",
       ".cython .ss { color: #19177C } /* Literal.String.Symbol */\n",
       ".cython .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
       ".cython .fm { color: #0000FF } /* Name.Function.Magic */\n",
       ".cython .vc { color: #19177C } /* Name.Variable.Class */\n",
       ".cython .vg { color: #19177C } /* Name.Variable.Global */\n",
       ".cython .vi { color: #19177C } /* Name.Variable.Instance */\n",
       ".cython .vm { color: #19177C } /* Name.Variable.Magic */\n",
       ".cython .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
       "    </style>\n",
       "</head>\n",
       "<body class=\"cython\">\n",
       "<p><span style=\"border-bottom: solid 1px grey;\">Generated by Cython 0.29.24</span></p>\n",
       "<p>\n",
       "    <span style=\"background-color: #FFFF00\">Yellow lines</span> hint at Python interaction.<br />\n",
       "    Click on a line that starts with a \"<code>+</code>\" to see the C code that Cython generated for it.\n",
       "</p>\n",
       "<div class=\"cython\"><pre class=\"cython line score-8\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">1</span>: <span class=\"k\">import</span> <span class=\"nn\">random</span></pre>\n",
       "<pre class='cython code score-8 '>  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_random, 0, 0);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_random, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 1, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "</pre><pre class=\"cython line score-25\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">2</span>: <span class=\"k\">def</span> <span class=\"nf\">mcs_pi_cy1</span><span class=\"p\">(</span><span class=\"nb\">int</span> <span class=\"n\">n</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-25 '>/* Python wrapper */\n",
       "static PyObject *__pyx_pw_46_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0_1mcs_pi_cy1(PyObject *__pyx_self, PyObject *__pyx_arg_n); /*proto*/\n",
       "static PyMethodDef __pyx_mdef_46_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0_1mcs_pi_cy1 = {\"mcs_pi_cy1\", (PyCFunction)__pyx_pw_46_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0_1mcs_pi_cy1, METH_O, 0};\n",
       "static PyObject *__pyx_pw_46_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0_1mcs_pi_cy1(PyObject *__pyx_self, PyObject *__pyx_arg_n) {\n",
       "  int __pyx_v_n;\n",
       "  PyObject *__pyx_r = 0;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"mcs_pi_cy1 (wrapper)\", 0);\n",
       "  assert(__pyx_arg_n); {\n",
       "    __pyx_v_n = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_arg_n); if (unlikely((__pyx_v_n == (int)-1) &amp;&amp; <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 2, __pyx_L3_error)</span>\n",
       "  }\n",
       "  goto __pyx_L4_argument_unpacking_done;\n",
       "  __pyx_L3_error:;\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0.mcs_pi_cy1\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return NULL;\n",
       "  __pyx_L4_argument_unpacking_done:;\n",
       "  __pyx_r = __pyx_pf_46_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0_mcs_pi_cy1(__pyx_self, ((int)__pyx_v_n));\n",
       "  int __pyx_lineno = 0;\n",
       "  const char *__pyx_filename = NULL;\n",
       "  int __pyx_clineno = 0;\n",
       "\n",
       "  /* function exit code */\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "\n",
       "static PyObject *__pyx_pf_46_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0_mcs_pi_cy1(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {\n",
       "  CYTHON_UNUSED int __pyx_v_i;\n",
       "  int __pyx_v_circle;\n",
       "  float __pyx_v_x;\n",
       "  float __pyx_v_y;\n",
       "  PyObject *__pyx_r = NULL;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"mcs_pi_cy1\", 0);\n",
       "/* … */\n",
       "  /* function exit code */\n",
       "  __pyx_L1_error:;\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_6);\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0.mcs_pi_cy1\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  __pyx_r = NULL;\n",
       "  __pyx_L0:;\n",
       "  <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "/* … */\n",
       "  __pyx_tuple_ = <span class='py_c_api'>PyTuple_Pack</span>(6, __pyx_n_s_n, __pyx_n_s_n, __pyx_n_s_i, __pyx_n_s_circle, __pyx_n_s_x, __pyx_n_s_y);<span class='error_goto'> if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 2, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple_);\n",
       "  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple_);\n",
       "/* … */\n",
       "  __pyx_t_1 = PyCFunction_NewEx(&amp;__pyx_mdef_46_cython_magic_92ae563c1590716bb0c3b88eca8f9fd0_1mcs_pi_cy1, NULL, __pyx_n_s_cython_magic_92ae563c1590716bb0);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_mcs_pi_cy1, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 2, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">3</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">int</span> <span class=\"nf\">i</span><span class=\"p\">,</span> <span class=\"nf\">circle</span> <span class=\"o\">=</span> <span class=\"mf\">0</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_circle = 0;\n",
       "</pre><pre class=\"cython line score-0\">&#xA0;<span class=\"\">4</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">x</span><span class=\"p\">,</span> <span class=\"nf\">y</span></pre>\n",
       "<pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">5</span>:     <span class=\"k\">for</span> <span class=\"n\">i</span> <span class=\"ow\">in</span> <span class=\"nb\">range</span><span class=\"p\">(</span><span class=\"n\">n</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_t_1 = __pyx_v_n;\n",
       "  __pyx_t_2 = __pyx_t_1;\n",
       "  for (__pyx_t_3 = 0; __pyx_t_3 &lt; __pyx_t_2; __pyx_t_3+=1) {\n",
       "    __pyx_v_i = __pyx_t_3;\n",
       "</pre><pre class=\"cython line score-64\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">6</span>:         <span class=\"n\">x</span><span class=\"p\">,</span> <span class=\"n\">y</span> <span class=\"o\">=</span> <span class=\"n\">random</span><span class=\"o\">.</span><span class=\"n\">random</span><span class=\"p\">(),</span> <span class=\"n\">random</span><span class=\"o\">.</span><span class=\"n\">random</span><span class=\"p\">()</span></pre>\n",
       "<pre class='cython code score-64 '>    <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_5, __pyx_n_s_random);<span class='error_goto'> if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);\n",
       "    __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_5, __pyx_n_s_random);<span class='error_goto'> if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;\n",
       "    __pyx_t_5 = NULL;\n",
       "    if (CYTHON_UNPACK_METHODS &amp;&amp; unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_6))) {\n",
       "      __pyx_t_5 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_6);\n",
       "      if (likely(__pyx_t_5)) {\n",
       "        PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_6);\n",
       "        <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_5);\n",
       "        <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);\n",
       "        <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_6, function);\n",
       "      }\n",
       "    }\n",
       "    __pyx_t_4 = (__pyx_t_5) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_6, __pyx_t_5) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_6);\n",
       "    <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5); __pyx_t_5 = 0;\n",
       "    if (unlikely(!__pyx_t_4)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;\n",
       "    __pyx_t_7 = __pyx_<span class='py_c_api'>PyFloat_AsFloat</span>(__pyx_t_4); if (unlikely((__pyx_t_7 == (float)-1) &amp;&amp; <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;\n",
       "    <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_6, __pyx_n_s_random);<span class='error_goto'> if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_6);\n",
       "    __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_6, __pyx_n_s_random);<span class='error_goto'> if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_6); __pyx_t_6 = 0;\n",
       "    __pyx_t_6 = NULL;\n",
       "    if (CYTHON_UNPACK_METHODS &amp;&amp; unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_5))) {\n",
       "      __pyx_t_6 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_5);\n",
       "      if (likely(__pyx_t_6)) {\n",
       "        PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_5);\n",
       "        <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_6);\n",
       "        <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);\n",
       "        <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_5, function);\n",
       "      }\n",
       "    }\n",
       "    __pyx_t_4 = (__pyx_t_6) ? <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_5, __pyx_t_6) : <span class='pyx_c_api'>__Pyx_PyObject_CallNoArg</span>(__pyx_t_5);\n",
       "    <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_6); __pyx_t_6 = 0;\n",
       "    if (unlikely(!__pyx_t_4)) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;\n",
       "    __pyx_t_8 = __pyx_<span class='py_c_api'>PyFloat_AsFloat</span>(__pyx_t_4); if (unlikely((__pyx_t_8 == (float)-1) &amp;&amp; <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 6, __pyx_L1_error)</span>\n",
       "    <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;\n",
       "    __pyx_v_x = __pyx_t_7;\n",
       "    __pyx_v_y = __pyx_t_8;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">7</span>:         <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">x</span> <span class=\"o\">**</span> <span class=\"mf\">2</span> <span class=\"o\">+</span> <span class=\"n\">y</span> <span class=\"o\">**</span> <span class=\"mf\">2</span><span class=\"p\">)</span> <span class=\"o\">**</span> <span class=\"mf\">0.5</span> <span class=\"o\">&lt;=</span> <span class=\"mf\">1</span><span class=\"p\">:</span></pre>\n",
       "<pre class='cython code score-0 '>    __pyx_t_9 = ((pow(((double)(powf(__pyx_v_x, 2.0) + powf(__pyx_v_y, 2.0))), 0.5) &lt;= 1.0) != 0);\n",
       "    if (__pyx_t_9) {\n",
       "/* … */\n",
       "    }\n",
       "  }\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">8</span>:             <span class=\"n\">circle</span> <span class=\"o\">+=</span> <span class=\"mf\">1</span></pre>\n",
       "<pre class='cython code score-0 '>      __pyx_v_circle = (__pyx_v_circle + 1);\n",
       "</pre><pre class=\"cython line score-11\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">9</span>:     <span class=\"k\">return</span> <span class=\"p\">(</span><span class=\"mf\">4</span> <span class=\"o\">*</span> <span class=\"n\">circle</span><span class=\"p\">)</span> <span class=\"o\">/</span> <span class=\"n\">n</span></pre>\n",
       "<pre class='cython code score-11 '>  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r);\n",
       "  __pyx_t_10 = (4 * __pyx_v_circle);\n",
       "  if (unlikely(__pyx_v_n == 0)) {\n",
       "    <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "    <span class='error_goto'>__PYX_ERR(0, 9, __pyx_L1_error)</span>\n",
       "  }\n",
       "  __pyx_t_4 = <span class='py_c_api'>PyFloat_FromDouble</span>((((double)__pyx_t_10) / ((double)__pyx_v_n)));<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);\n",
       "  __pyx_r = __pyx_t_4;\n",
       "  __pyx_t_4 = 0;\n",
       "  goto __pyx_L0;\n",
       "</pre></div></body></html>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%cython -a\n",
    "import random\n",
    "def mcs_pi_cy1(int n):\n",
    "    cdef int i, circle = 0\n",
    "    cdef float x, y\n",
    "    for i in range(n):\n",
    "        x, y = random.random(), random.random()\n",
    "        if (x ** 2 + y ** 2) ** 0.5 <= 1:\n",
    "            circle += 1\n",
    "    return (4 * circle) / n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 930 ms, sys: 5.91 ms, total: 936 ms\n",
      "Wall time: 934 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "3.1422212"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time mcs_pi_cy1(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<!-- Generated by Cython 0.29.24 -->\n",
       "<html>\n",
       "<head>\n",
       "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n",
       "    <title>Cython: _cython_magic_e5404ed78e1f57380959b65865ecfdb9.pyx</title>\n",
       "    <style type=\"text/css\">\n",
       "    \n",
       "body.cython { font-family: courier; font-size: 12; }\n",
       "\n",
       ".cython.tag  {  }\n",
       ".cython.line { margin: 0em }\n",
       ".cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; }\n",
       "\n",
       ".cython.line .run { background-color: #B0FFB0; }\n",
       ".cython.line .mis { background-color: #FFB0B0; }\n",
       ".cython.code.run  { border-left: 8px solid #B0FFB0; }\n",
       ".cython.code.mis  { border-left: 8px solid #FFB0B0; }\n",
       "\n",
       ".cython.code .py_c_api  { color: red; }\n",
       ".cython.code .py_macro_api  { color: #FF7000; }\n",
       ".cython.code .pyx_c_api  { color: #FF3000; }\n",
       ".cython.code .pyx_macro_api  { color: #FF7000; }\n",
       ".cython.code .refnanny  { color: #FFA000; }\n",
       ".cython.code .trace  { color: #FFA000; }\n",
       ".cython.code .error_goto  { color: #FFA000; }\n",
       "\n",
       ".cython.code .coerce  { color: #008000; border: 1px dotted #008000 }\n",
       ".cython.code .py_attr { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_attr  { color: #0000FF; }\n",
       ".cython.code .py_call { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_call  { color: #0000FF; }\n",
       "\n",
       ".cython.score-0 {background-color: #FFFFff;}\n",
       ".cython.score-1 {background-color: #FFFFe7;}\n",
       ".cython.score-2 {background-color: #FFFFd4;}\n",
       ".cython.score-3 {background-color: #FFFFc4;}\n",
       ".cython.score-4 {background-color: #FFFFb6;}\n",
       ".cython.score-5 {background-color: #FFFFaa;}\n",
       ".cython.score-6 {background-color: #FFFF9f;}\n",
       ".cython.score-7 {background-color: #FFFF96;}\n",
       ".cython.score-8 {background-color: #FFFF8d;}\n",
       ".cython.score-9 {background-color: #FFFF86;}\n",
       ".cython.score-10 {background-color: #FFFF7f;}\n",
       ".cython.score-11 {background-color: #FFFF79;}\n",
       ".cython.score-12 {background-color: #FFFF73;}\n",
       ".cython.score-13 {background-color: #FFFF6e;}\n",
       ".cython.score-14 {background-color: #FFFF6a;}\n",
       ".cython.score-15 {background-color: #FFFF66;}\n",
       ".cython.score-16 {background-color: #FFFF62;}\n",
       ".cython.score-17 {background-color: #FFFF5e;}\n",
       ".cython.score-18 {background-color: #FFFF5b;}\n",
       ".cython.score-19 {background-color: #FFFF57;}\n",
       ".cython.score-20 {background-color: #FFFF55;}\n",
       ".cython.score-21 {background-color: #FFFF52;}\n",
       ".cython.score-22 {background-color: #FFFF4f;}\n",
       ".cython.score-23 {background-color: #FFFF4d;}\n",
       ".cython.score-24 {background-color: #FFFF4b;}\n",
       ".cython.score-25 {background-color: #FFFF48;}\n",
       ".cython.score-26 {background-color: #FFFF46;}\n",
       ".cython.score-27 {background-color: #FFFF44;}\n",
       ".cython.score-28 {background-color: #FFFF43;}\n",
       ".cython.score-29 {background-color: #FFFF41;}\n",
       ".cython.score-30 {background-color: #FFFF3f;}\n",
       ".cython.score-31 {background-color: #FFFF3e;}\n",
       ".cython.score-32 {background-color: #FFFF3c;}\n",
       ".cython.score-33 {background-color: #FFFF3b;}\n",
       ".cython.score-34 {background-color: #FFFF39;}\n",
       ".cython.score-35 {background-color: #FFFF38;}\n",
       ".cython.score-36 {background-color: #FFFF37;}\n",
       ".cython.score-37 {background-color: #FFFF36;}\n",
       ".cython.score-38 {background-color: #FFFF35;}\n",
       ".cython.score-39 {background-color: #FFFF34;}\n",
       ".cython.score-40 {background-color: #FFFF33;}\n",
       ".cython.score-41 {background-color: #FFFF32;}\n",
       ".cython.score-42 {background-color: #FFFF31;}\n",
       ".cython.score-43 {background-color: #FFFF30;}\n",
       ".cython.score-44 {background-color: #FFFF2f;}\n",
       ".cython.score-45 {background-color: #FFFF2e;}\n",
       ".cython.score-46 {background-color: #FFFF2d;}\n",
       ".cython.score-47 {background-color: #FFFF2c;}\n",
       ".cython.score-48 {background-color: #FFFF2b;}\n",
       ".cython.score-49 {background-color: #FFFF2b;}\n",
       ".cython.score-50 {background-color: #FFFF2a;}\n",
       ".cython.score-51 {background-color: #FFFF29;}\n",
       ".cython.score-52 {background-color: #FFFF29;}\n",
       ".cython.score-53 {background-color: #FFFF28;}\n",
       ".cython.score-54 {background-color: #FFFF27;}\n",
       ".cython.score-55 {background-color: #FFFF27;}\n",
       ".cython.score-56 {background-color: #FFFF26;}\n",
       ".cython.score-57 {background-color: #FFFF26;}\n",
       ".cython.score-58 {background-color: #FFFF25;}\n",
       ".cython.score-59 {background-color: #FFFF24;}\n",
       ".cython.score-60 {background-color: #FFFF24;}\n",
       ".cython.score-61 {background-color: #FFFF23;}\n",
       ".cython.score-62 {background-color: #FFFF23;}\n",
       ".cython.score-63 {background-color: #FFFF22;}\n",
       ".cython.score-64 {background-color: #FFFF22;}\n",
       ".cython.score-65 {background-color: #FFFF22;}\n",
       ".cython.score-66 {background-color: #FFFF21;}\n",
       ".cython.score-67 {background-color: #FFFF21;}\n",
       ".cython.score-68 {background-color: #FFFF20;}\n",
       ".cython.score-69 {background-color: #FFFF20;}\n",
       ".cython.score-70 {background-color: #FFFF1f;}\n",
       ".cython.score-71 {background-color: #FFFF1f;}\n",
       ".cython.score-72 {background-color: #FFFF1f;}\n",
       ".cython.score-73 {background-color: #FFFF1e;}\n",
       ".cython.score-74 {background-color: #FFFF1e;}\n",
       ".cython.score-75 {background-color: #FFFF1e;}\n",
       ".cython.score-76 {background-color: #FFFF1d;}\n",
       ".cython.score-77 {background-color: #FFFF1d;}\n",
       ".cython.score-78 {background-color: #FFFF1c;}\n",
       ".cython.score-79 {background-color: #FFFF1c;}\n",
       ".cython.score-80 {background-color: #FFFF1c;}\n",
       ".cython.score-81 {background-color: #FFFF1c;}\n",
       ".cython.score-82 {background-color: #FFFF1b;}\n",
       ".cython.score-83 {background-color: #FFFF1b;}\n",
       ".cython.score-84 {background-color: #FFFF1b;}\n",
       ".cython.score-85 {background-color: #FFFF1a;}\n",
       ".cython.score-86 {background-color: #FFFF1a;}\n",
       ".cython.score-87 {background-color: #FFFF1a;}\n",
       ".cython.score-88 {background-color: #FFFF1a;}\n",
       ".cython.score-89 {background-color: #FFFF19;}\n",
       ".cython.score-90 {background-color: #FFFF19;}\n",
       ".cython.score-91 {background-color: #FFFF19;}\n",
       ".cython.score-92 {background-color: #FFFF19;}\n",
       ".cython.score-93 {background-color: #FFFF18;}\n",
       ".cython.score-94 {background-color: #FFFF18;}\n",
       ".cython.score-95 {background-color: #FFFF18;}\n",
       ".cython.score-96 {background-color: #FFFF18;}\n",
       ".cython.score-97 {background-color: #FFFF17;}\n",
       ".cython.score-98 {background-color: #FFFF17;}\n",
       ".cython.score-99 {background-color: #FFFF17;}\n",
       ".cython.score-100 {background-color: #FFFF17;}\n",
       ".cython.score-101 {background-color: #FFFF16;}\n",
       ".cython.score-102 {background-color: #FFFF16;}\n",
       ".cython.score-103 {background-color: #FFFF16;}\n",
       ".cython.score-104 {background-color: #FFFF16;}\n",
       ".cython.score-105 {background-color: #FFFF16;}\n",
       ".cython.score-106 {background-color: #FFFF15;}\n",
       ".cython.score-107 {background-color: #FFFF15;}\n",
       ".cython.score-108 {background-color: #FFFF15;}\n",
       ".cython.score-109 {background-color: #FFFF15;}\n",
       ".cython.score-110 {background-color: #FFFF15;}\n",
       ".cython.score-111 {background-color: #FFFF15;}\n",
       ".cython.score-112 {background-color: #FFFF14;}\n",
       ".cython.score-113 {background-color: #FFFF14;}\n",
       ".cython.score-114 {background-color: #FFFF14;}\n",
       ".cython.score-115 {background-color: #FFFF14;}\n",
       ".cython.score-116 {background-color: #FFFF14;}\n",
       ".cython.score-117 {background-color: #FFFF14;}\n",
       ".cython.score-118 {background-color: #FFFF13;}\n",
       ".cython.score-119 {background-color: #FFFF13;}\n",
       ".cython.score-120 {background-color: #FFFF13;}\n",
       ".cython.score-121 {background-color: #FFFF13;}\n",
       ".cython.score-122 {background-color: #FFFF13;}\n",
       ".cython.score-123 {background-color: #FFFF13;}\n",
       ".cython.score-124 {background-color: #FFFF13;}\n",
       ".cython.score-125 {background-color: #FFFF12;}\n",
       ".cython.score-126 {background-color: #FFFF12;}\n",
       ".cython.score-127 {background-color: #FFFF12;}\n",
       ".cython.score-128 {background-color: #FFFF12;}\n",
       ".cython.score-129 {background-color: #FFFF12;}\n",
       ".cython.score-130 {background-color: #FFFF12;}\n",
       ".cython.score-131 {background-color: #FFFF12;}\n",
       ".cython.score-132 {background-color: #FFFF11;}\n",
       ".cython.score-133 {background-color: #FFFF11;}\n",
       ".cython.score-134 {background-color: #FFFF11;}\n",
       ".cython.score-135 {background-color: #FFFF11;}\n",
       ".cython.score-136 {background-color: #FFFF11;}\n",
       ".cython.score-137 {background-color: #FFFF11;}\n",
       ".cython.score-138 {background-color: #FFFF11;}\n",
       ".cython.score-139 {background-color: #FFFF11;}\n",
       ".cython.score-140 {background-color: #FFFF11;}\n",
       ".cython.score-141 {background-color: #FFFF10;}\n",
       ".cython.score-142 {background-color: #FFFF10;}\n",
       ".cython.score-143 {background-color: #FFFF10;}\n",
       ".cython.score-144 {background-color: #FFFF10;}\n",
       ".cython.score-145 {background-color: #FFFF10;}\n",
       ".cython.score-146 {background-color: #FFFF10;}\n",
       ".cython.score-147 {background-color: #FFFF10;}\n",
       ".cython.score-148 {background-color: #FFFF10;}\n",
       ".cython.score-149 {background-color: #FFFF10;}\n",
       ".cython.score-150 {background-color: #FFFF0f;}\n",
       ".cython.score-151 {background-color: #FFFF0f;}\n",
       ".cython.score-152 {background-color: #FFFF0f;}\n",
       ".cython.score-153 {background-color: #FFFF0f;}\n",
       ".cython.score-154 {background-color: #FFFF0f;}\n",
       ".cython.score-155 {background-color: #FFFF0f;}\n",
       ".cython.score-156 {background-color: #FFFF0f;}\n",
       ".cython.score-157 {background-color: #FFFF0f;}\n",
       ".cython.score-158 {background-color: #FFFF0f;}\n",
       ".cython.score-159 {background-color: #FFFF0f;}\n",
       ".cython.score-160 {background-color: #FFFF0f;}\n",
       ".cython.score-161 {background-color: #FFFF0e;}\n",
       ".cython.score-162 {background-color: #FFFF0e;}\n",
       ".cython.score-163 {background-color: #FFFF0e;}\n",
       ".cython.score-164 {background-color: #FFFF0e;}\n",
       ".cython.score-165 {background-color: #FFFF0e;}\n",
       ".cython.score-166 {background-color: #FFFF0e;}\n",
       ".cython.score-167 {background-color: #FFFF0e;}\n",
       ".cython.score-168 {background-color: #FFFF0e;}\n",
       ".cython.score-169 {background-color: #FFFF0e;}\n",
       ".cython.score-170 {background-color: #FFFF0e;}\n",
       ".cython.score-171 {background-color: #FFFF0e;}\n",
       ".cython.score-172 {background-color: #FFFF0e;}\n",
       ".cython.score-173 {background-color: #FFFF0d;}\n",
       ".cython.score-174 {background-color: #FFFF0d;}\n",
       ".cython.score-175 {background-color: #FFFF0d;}\n",
       ".cython.score-176 {background-color: #FFFF0d;}\n",
       ".cython.score-177 {background-color: #FFFF0d;}\n",
       ".cython.score-178 {background-color: #FFFF0d;}\n",
       ".cython.score-179 {background-color: #FFFF0d;}\n",
       ".cython.score-180 {background-color: #FFFF0d;}\n",
       ".cython.score-181 {background-color: #FFFF0d;}\n",
       ".cython.score-182 {background-color: #FFFF0d;}\n",
       ".cython.score-183 {background-color: #FFFF0d;}\n",
       ".cython.score-184 {background-color: #FFFF0d;}\n",
       ".cython.score-185 {background-color: #FFFF0d;}\n",
       ".cython.score-186 {background-color: #FFFF0d;}\n",
       ".cython.score-187 {background-color: #FFFF0c;}\n",
       ".cython.score-188 {background-color: #FFFF0c;}\n",
       ".cython.score-189 {background-color: #FFFF0c;}\n",
       ".cython.score-190 {background-color: #FFFF0c;}\n",
       ".cython.score-191 {background-color: #FFFF0c;}\n",
       ".cython.score-192 {background-color: #FFFF0c;}\n",
       ".cython.score-193 {background-color: #FFFF0c;}\n",
       ".cython.score-194 {background-color: #FFFF0c;}\n",
       ".cython.score-195 {background-color: #FFFF0c;}\n",
       ".cython.score-196 {background-color: #FFFF0c;}\n",
       ".cython.score-197 {background-color: #FFFF0c;}\n",
       ".cython.score-198 {background-color: #FFFF0c;}\n",
       ".cython.score-199 {background-color: #FFFF0c;}\n",
       ".cython.score-200 {background-color: #FFFF0c;}\n",
       ".cython.score-201 {background-color: #FFFF0c;}\n",
       ".cython.score-202 {background-color: #FFFF0c;}\n",
       ".cython.score-203 {background-color: #FFFF0b;}\n",
       ".cython.score-204 {background-color: #FFFF0b;}\n",
       ".cython.score-205 {background-color: #FFFF0b;}\n",
       ".cython.score-206 {background-color: #FFFF0b;}\n",
       ".cython.score-207 {background-color: #FFFF0b;}\n",
       ".cython.score-208 {background-color: #FFFF0b;}\n",
       ".cython.score-209 {background-color: #FFFF0b;}\n",
       ".cython.score-210 {background-color: #FFFF0b;}\n",
       ".cython.score-211 {background-color: #FFFF0b;}\n",
       ".cython.score-212 {background-color: #FFFF0b;}\n",
       ".cython.score-213 {background-color: #FFFF0b;}\n",
       ".cython.score-214 {background-color: #FFFF0b;}\n",
       ".cython.score-215 {background-color: #FFFF0b;}\n",
       ".cython.score-216 {background-color: #FFFF0b;}\n",
       ".cython.score-217 {background-color: #FFFF0b;}\n",
       ".cython.score-218 {background-color: #FFFF0b;}\n",
       ".cython.score-219 {background-color: #FFFF0b;}\n",
       ".cython.score-220 {background-color: #FFFF0b;}\n",
       ".cython.score-221 {background-color: #FFFF0b;}\n",
       ".cython.score-222 {background-color: #FFFF0a;}\n",
       ".cython.score-223 {background-color: #FFFF0a;}\n",
       ".cython.score-224 {background-color: #FFFF0a;}\n",
       ".cython.score-225 {background-color: #FFFF0a;}\n",
       ".cython.score-226 {background-color: #FFFF0a;}\n",
       ".cython.score-227 {background-color: #FFFF0a;}\n",
       ".cython.score-228 {background-color: #FFFF0a;}\n",
       ".cython.score-229 {background-color: #FFFF0a;}\n",
       ".cython.score-230 {background-color: #FFFF0a;}\n",
       ".cython.score-231 {background-color: #FFFF0a;}\n",
       ".cython.score-232 {background-color: #FFFF0a;}\n",
       ".cython.score-233 {background-color: #FFFF0a;}\n",
       ".cython.score-234 {background-color: #FFFF0a;}\n",
       ".cython.score-235 {background-color: #FFFF0a;}\n",
       ".cython.score-236 {background-color: #FFFF0a;}\n",
       ".cython.score-237 {background-color: #FFFF0a;}\n",
       ".cython.score-238 {background-color: #FFFF0a;}\n",
       ".cython.score-239 {background-color: #FFFF0a;}\n",
       ".cython.score-240 {background-color: #FFFF0a;}\n",
       ".cython.score-241 {background-color: #FFFF0a;}\n",
       ".cython.score-242 {background-color: #FFFF0a;}\n",
       ".cython.score-243 {background-color: #FFFF0a;}\n",
       ".cython.score-244 {background-color: #FFFF0a;}\n",
       ".cython.score-245 {background-color: #FFFF0a;}\n",
       ".cython.score-246 {background-color: #FFFF09;}\n",
       ".cython.score-247 {background-color: #FFFF09;}\n",
       ".cython.score-248 {background-color: #FFFF09;}\n",
       ".cython.score-249 {background-color: #FFFF09;}\n",
       ".cython.score-250 {background-color: #FFFF09;}\n",
       ".cython.score-251 {background-color: #FFFF09;}\n",
       ".cython.score-252 {background-color: #FFFF09;}\n",
       ".cython.score-253 {background-color: #FFFF09;}\n",
       ".cython.score-254 {background-color: #FFFF09;}\n",
       "pre { line-height: 125%; }\n",
       "td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       ".cython .hll { background-color: #ffffcc }\n",
       ".cython { background: #f8f8f8; }\n",
       ".cython .c { color: #408080; font-style: italic } /* Comment */\n",
       ".cython .err { border: 1px solid #FF0000 } /* Error */\n",
       ".cython .k { color: #008000; font-weight: bold } /* Keyword */\n",
       ".cython .o { color: #666666 } /* Operator */\n",
       ".cython .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
       ".cython .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
       ".cython .cp { color: #BC7A00 } /* Comment.Preproc */\n",
       ".cython .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
       ".cython .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
       ".cython .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
       ".cython .gd { color: #A00000 } /* Generic.Deleted */\n",
       ".cython .ge { font-style: italic } /* Generic.Emph */\n",
       ".cython .gr { color: #FF0000 } /* Generic.Error */\n",
       ".cython .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
       ".cython .gi { color: #00A000 } /* Generic.Inserted */\n",
       ".cython .go { color: #888888 } /* Generic.Output */\n",
       ".cython .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
       ".cython .gs { font-weight: bold } /* Generic.Strong */\n",
       ".cython .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
       ".cython .gt { color: #0044DD } /* Generic.Traceback */\n",
       ".cython .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
       ".cython .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
       ".cython .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
       ".cython .kp { color: #008000 } /* Keyword.Pseudo */\n",
       ".cython .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
       ".cython .kt { color: #B00040 } /* Keyword.Type */\n",
       ".cython .m { color: #666666 } /* Literal.Number */\n",
       ".cython .s { color: #BA2121 } /* Literal.String */\n",
       ".cython .na { color: #7D9029 } /* Name.Attribute */\n",
       ".cython .nb { color: #008000 } /* Name.Builtin */\n",
       ".cython .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
       ".cython .no { color: #880000 } /* Name.Constant */\n",
       ".cython .nd { color: #AA22FF } /* Name.Decorator */\n",
       ".cython .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
       ".cython .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
       ".cython .nf { color: #0000FF } /* Name.Function */\n",
       ".cython .nl { color: #A0A000 } /* Name.Label */\n",
       ".cython .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
       ".cython .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
       ".cython .nv { color: #19177C } /* Name.Variable */\n",
       ".cython .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
       ".cython .w { color: #bbbbbb } /* Text.Whitespace */\n",
       ".cython .mb { color: #666666 } /* Literal.Number.Bin */\n",
       ".cython .mf { color: #666666 } /* Literal.Number.Float */\n",
       ".cython .mh { color: #666666 } /* Literal.Number.Hex */\n",
       ".cython .mi { color: #666666 } /* Literal.Number.Integer */\n",
       ".cython .mo { color: #666666 } /* Literal.Number.Oct */\n",
       ".cython .sa { color: #BA2121 } /* Literal.String.Affix */\n",
       ".cython .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
       ".cython .sc { color: #BA2121 } /* Literal.String.Char */\n",
       ".cython .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
       ".cython .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
       ".cython .s2 { color: #BA2121 } /* Literal.String.Double */\n",
       ".cython .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
       ".cython .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
       ".cython .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
       ".cython .sx { color: #008000 } /* Literal.String.Other */\n",
       ".cython .sr { color: #BB6688 } /* Literal.String.Regex */\n",
       ".cython .s1 { color: #BA2121 } /* Literal.String.Single */\n",
       ".cython .ss { color: #19177C } /* Literal.String.Symbol */\n",
       ".cython .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
       ".cython .fm { color: #0000FF } /* Name.Function.Magic */\n",
       ".cython .vc { color: #19177C } /* Name.Variable.Class */\n",
       ".cython .vg { color: #19177C } /* Name.Variable.Global */\n",
       ".cython .vi { color: #19177C } /* Name.Variable.Instance */\n",
       ".cython .vm { color: #19177C } /* Name.Variable.Magic */\n",
       ".cython .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
       "    </style>\n",
       "</head>\n",
       "<body class=\"cython\">\n",
       "<p><span style=\"border-bottom: solid 1px grey;\">Generated by Cython 0.29.24</span></p>\n",
       "<p>\n",
       "    <span style=\"background-color: #FFFF00\">Yellow lines</span> hint at Python interaction.<br />\n",
       "    Click on a line that starts with a \"<code>+</code>\" to see the C code that Cython generated for it.\n",
       "</p>\n",
       "<div class=\"cython\"><pre class=\"cython line score-0\">&#xA0;<span class=\"\">01</span>: <span class=\"k\">from</span> <span class=\"nn\">libc.stdlib</span> <span class=\"k\">cimport</span> <span class=\"n\">rand</span></pre>\n",
       "<pre class=\"cython line score-0\">&#xA0;<span class=\"\">02</span>: <span class=\"k\">cdef</span> <span class=\"kr\">extern</span> <span class=\"k\">from</span> <span class=\"s\">&#39;limits.h&#39;</span><span class=\"p\">:</span></pre>\n",
       "<pre class=\"cython line score-0\">&#xA0;<span class=\"\">03</span>:     <span class=\"nb\">int</span> <span class=\"n\">INT_MAX</span></pre>\n",
       "<pre class=\"cython line score-23\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">04</span>: <span class=\"k\">def</span> <span class=\"nf\">mcs_pi_cy2</span><span class=\"p\">(</span><span class=\"nb\">int</span> <span class=\"n\">n</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-23 '>/* Python wrapper */\n",
       "static PyObject *__pyx_pw_46_cython_magic_e5404ed78e1f57380959b65865ecfdb9_1mcs_pi_cy2(PyObject *__pyx_self, PyObject *__pyx_arg_n); /*proto*/\n",
       "static PyMethodDef __pyx_mdef_46_cython_magic_e5404ed78e1f57380959b65865ecfdb9_1mcs_pi_cy2 = {\"mcs_pi_cy2\", (PyCFunction)__pyx_pw_46_cython_magic_e5404ed78e1f57380959b65865ecfdb9_1mcs_pi_cy2, METH_O, 0};\n",
       "static PyObject *__pyx_pw_46_cython_magic_e5404ed78e1f57380959b65865ecfdb9_1mcs_pi_cy2(PyObject *__pyx_self, PyObject *__pyx_arg_n) {\n",
       "  int __pyx_v_n;\n",
       "  PyObject *__pyx_r = 0;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"mcs_pi_cy2 (wrapper)\", 0);\n",
       "  assert(__pyx_arg_n); {\n",
       "    __pyx_v_n = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_arg_n); if (unlikely((__pyx_v_n == (int)-1) &amp;&amp; <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 4, __pyx_L3_error)</span>\n",
       "  }\n",
       "  goto __pyx_L4_argument_unpacking_done;\n",
       "  __pyx_L3_error:;\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_e5404ed78e1f57380959b65865ecfdb9.mcs_pi_cy2\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return NULL;\n",
       "  __pyx_L4_argument_unpacking_done:;\n",
       "  __pyx_r = __pyx_pf_46_cython_magic_e5404ed78e1f57380959b65865ecfdb9_mcs_pi_cy2(__pyx_self, ((int)__pyx_v_n));\n",
       "  int __pyx_lineno = 0;\n",
       "  const char *__pyx_filename = NULL;\n",
       "  int __pyx_clineno = 0;\n",
       "\n",
       "  /* function exit code */\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "\n",
       "static PyObject *__pyx_pf_46_cython_magic_e5404ed78e1f57380959b65865ecfdb9_mcs_pi_cy2(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_n) {\n",
       "  CYTHON_UNUSED int __pyx_v_i;\n",
       "  int __pyx_v_circle;\n",
       "  float __pyx_v_x;\n",
       "  float __pyx_v_y;\n",
       "  PyObject *__pyx_r = NULL;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"mcs_pi_cy2\", 0);\n",
       "/* … */\n",
       "  /* function exit code */\n",
       "  __pyx_L1_error:;\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_9);\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_e5404ed78e1f57380959b65865ecfdb9.mcs_pi_cy2\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  __pyx_r = NULL;\n",
       "  __pyx_L0:;\n",
       "  <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "/* … */\n",
       "  __pyx_tuple_ = <span class='py_c_api'>PyTuple_Pack</span>(6, __pyx_n_s_n, __pyx_n_s_n, __pyx_n_s_i, __pyx_n_s_circle, __pyx_n_s_x, __pyx_n_s_y);<span class='error_goto'> if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 4, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple_);\n",
       "  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple_);\n",
       "/* … */\n",
       "  __pyx_t_1 = PyCFunction_NewEx(&amp;__pyx_mdef_46_cython_magic_e5404ed78e1f57380959b65865ecfdb9_1mcs_pi_cy2, NULL, __pyx_n_s_cython_magic_e5404ed78e1f573809);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_mcs_pi_cy2, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 4, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">05</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">int</span> <span class=\"nf\">i</span><span class=\"p\">,</span> <span class=\"nf\">circle</span> <span class=\"o\">=</span> <span class=\"mf\">0</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_circle = 0;\n",
       "</pre><pre class=\"cython line score-0\">&#xA0;<span class=\"\">06</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">x</span><span class=\"p\">,</span> <span class=\"nf\">y</span></pre>\n",
       "<pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">07</span>:     <span class=\"k\">for</span> <span class=\"n\">i</span> <span class=\"ow\">in</span> <span class=\"nb\">range</span><span class=\"p\">(</span><span class=\"n\">n</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_t_1 = __pyx_v_n;\n",
       "  __pyx_t_2 = __pyx_t_1;\n",
       "  for (__pyx_t_3 = 0; __pyx_t_3 &lt; __pyx_t_2; __pyx_t_3+=1) {\n",
       "    __pyx_v_i = __pyx_t_3;\n",
       "</pre><pre class=\"cython line score-10\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">08</span>:         <span class=\"n\">x</span><span class=\"p\">,</span> <span class=\"n\">y</span> <span class=\"o\">=</span> <span class=\"n\">rand</span><span class=\"p\">()</span> <span class=\"o\">/</span> <span class=\"n\">INT_MAX</span><span class=\"p\">,</span> <span class=\"n\">rand</span><span class=\"p\">()</span> <span class=\"o\">/</span> <span class=\"n\">INT_MAX</span></pre>\n",
       "<pre class='cython code score-10 '>    __pyx_t_4 = rand();\n",
       "    if (unlikely(INT_MAX == 0)) {\n",
       "      <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "      <span class='error_goto'>__PYX_ERR(0, 8, __pyx_L1_error)</span>\n",
       "    }\n",
       "    __pyx_t_5 = (((double)__pyx_t_4) / ((double)INT_MAX));\n",
       "    __pyx_t_4 = rand();\n",
       "    if (unlikely(INT_MAX == 0)) {\n",
       "      <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "      <span class='error_goto'>__PYX_ERR(0, 8, __pyx_L1_error)</span>\n",
       "    }\n",
       "    __pyx_t_6 = (((double)__pyx_t_4) / ((double)INT_MAX));\n",
       "    __pyx_v_x = __pyx_t_5;\n",
       "    __pyx_v_y = __pyx_t_6;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">09</span>:         <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">x</span> <span class=\"o\">**</span> <span class=\"mf\">2</span> <span class=\"o\">+</span> <span class=\"n\">y</span> <span class=\"o\">**</span> <span class=\"mf\">2</span><span class=\"p\">)</span> <span class=\"o\">**</span> <span class=\"mf\">0.5</span> <span class=\"o\">&lt;=</span> <span class=\"mf\">1</span><span class=\"p\">:</span></pre>\n",
       "<pre class='cython code score-0 '>    __pyx_t_7 = ((pow(((double)(powf(__pyx_v_x, 2.0) + powf(__pyx_v_y, 2.0))), 0.5) &lt;= 1.0) != 0);\n",
       "    if (__pyx_t_7) {\n",
       "/* … */\n",
       "    }\n",
       "  }\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">10</span>:             <span class=\"n\">circle</span> <span class=\"o\">+=</span> <span class=\"mf\">1</span></pre>\n",
       "<pre class='cython code score-0 '>      __pyx_v_circle = (__pyx_v_circle + 1);\n",
       "</pre><pre class=\"cython line score-11\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">11</span>:     <span class=\"k\">return</span> <span class=\"p\">(</span><span class=\"mf\">4</span> <span class=\"o\">*</span> <span class=\"n\">circle</span><span class=\"p\">)</span> <span class=\"o\">/</span> <span class=\"n\">n</span></pre>\n",
       "<pre class='cython code score-11 '>  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r);\n",
       "  __pyx_t_8 = (4 * __pyx_v_circle);\n",
       "  if (unlikely(__pyx_v_n == 0)) {\n",
       "    <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "    <span class='error_goto'>__PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  }\n",
       "  __pyx_t_9 = <span class='py_c_api'>PyFloat_FromDouble</span>((((double)__pyx_t_8) / ((double)__pyx_v_n)));<span class='error_goto'> if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_9);\n",
       "  __pyx_r = __pyx_t_9;\n",
       "  __pyx_t_9 = 0;\n",
       "  goto __pyx_L0;\n",
       "</pre></div></body></html>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%cython -a\n",
    "from libc.stdlib cimport rand\n",
    "cdef extern from 'limits.h':\n",
    "    int INT_MAX\n",
    "def mcs_pi_cy2(int n):\n",
    "    cdef int i, circle = 0\n",
    "    cdef float x, y\n",
    "    for i in range(n):\n",
    "        x, y = rand() / INT_MAX, rand() / INT_MAX\n",
    "        if (x ** 2 + y ** 2) ** 0.5 <= 1:\n",
    "            circle += 1\n",
    "    return (4 * circle) / n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 116 ms, sys: 816 µs, total: 117 ms\n",
      "Wall time: 117 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "3.1419388"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time mcs_pi_cy2(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Binomial Trees"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [],
   "source": [
    "import math"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [],
   "source": [
    "S0 = 36.  \n",
    "T = 1.0  \n",
    "r = 0.06  \n",
    "sigma = 0.2  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [],
   "source": [
    "def simulate_tree(M):\n",
    "    dt = T / M  \n",
    "    u = math.exp(sigma * math.sqrt(dt))  \n",
    "    d = 1 / u  \n",
    "    S = np.zeros((M + 1, M + 1))\n",
    "    S[0, 0] = S0\n",
    "    z = 1\n",
    "    for t in range(1, M + 1):\n",
    "        for i in range(z):\n",
    "            S[i, t] = S[i, t-1] * u\n",
    "            S[i+1, t] = S[i, t-1] * d\n",
    "        z += 1\n",
    "    return S"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.set_printoptions(formatter={'float':\n",
    "                               lambda x: '%6.2f' % x})  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  39.79,  43.97,  48.59,  53.71],\n",
       "       [  0.00,  32.57,  36.00,  39.79,  43.97],\n",
       "       [  0.00,   0.00,  29.47,  32.57,  36.00],\n",
       "       [  0.00,   0.00,   0.00,  26.67,  29.47],\n",
       "       [  0.00,   0.00,   0.00,   0.00,  24.13]])"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simulate_tree(4)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 106 ms, sys: 3.82 ms, total: 110 ms\n",
      "Wall time: 107 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  36.32,  36.65, ..., 3095.69, 3123.50, 3151.57],\n",
       "       [  0.00,  35.68,  36.00, ..., 3040.81, 3068.13, 3095.69],\n",
       "       [  0.00,   0.00,  35.36, ..., 2986.89, 3013.73, 3040.81],\n",
       "       ...,\n",
       "       [  0.00,   0.00,   0.00, ...,   0.42,   0.42,   0.43],\n",
       "       [  0.00,   0.00,   0.00, ...,   0.00,   0.41,   0.42],\n",
       "       [  0.00,   0.00,   0.00, ...,   0.00,   0.00,   0.41]])"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time simulate_tree(500)  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### NumPy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [],
   "source": [
    "M = 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 1, 2, 3, 4],\n",
       "       [0, 1, 2, 3, 4],\n",
       "       [0, 1, 2, 3, 4],\n",
       "       [0, 1, 2, 3, 4],\n",
       "       [0, 1, 2, 3, 4]])"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "up = np.arange(M + 1)\n",
    "up = np.resize(up, (M + 1, M + 1))  \n",
    "up"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0, 0, 0],\n",
       "       [2, 2, 2, 2, 2],\n",
       "       [4, 4, 4, 4, 4],\n",
       "       [6, 6, 6, 6, 6],\n",
       "       [8, 8, 8, 8, 8]])"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "down = up.T * 2  \n",
    "down"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0,  1,  2,  3,  4],\n",
       "       [-2, -1,  0,  1,  2],\n",
       "       [-4, -3, -2, -1,  0],\n",
       "       [-6, -5, -4, -3, -2],\n",
       "       [-8, -7, -6, -5, -4]])"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "up - down  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [],
   "source": [
    "dt = T / M"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  39.79,  43.97,  48.59,  53.71],\n",
       "       [ 29.47,  32.57,  36.00,  39.79,  43.97],\n",
       "       [ 24.13,  26.67,  29.47,  32.57,  36.00],\n",
       "       [ 19.76,  21.84,  24.13,  26.67,  29.47],\n",
       "       [ 16.18,  17.88,  19.76,  21.84,  24.13]])"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S0 * np.exp(sigma * math.sqrt(dt) * (up - down))  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [],
   "source": [
    "def simulate_tree_np(M):\n",
    "    dt = T / M\n",
    "    up = np.arange(M + 1)\n",
    "    up = np.resize(up, (M + 1, M + 1))\n",
    "    down = up.transpose() * 2\n",
    "    S = S0 * np.exp(sigma * math.sqrt(dt) * (up - down))\n",
    "    return S"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  39.79,  43.97,  48.59,  53.71],\n",
       "       [ 29.47,  32.57,  36.00,  39.79,  43.97],\n",
       "       [ 24.13,  26.67,  29.47,  32.57,  36.00],\n",
       "       [ 19.76,  21.84,  24.13,  26.67,  29.47],\n",
       "       [ 16.18,  17.88,  19.76,  21.84,  24.13]])"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simulate_tree_np(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 6.2 ms, sys: 8.22 ms, total: 14.4 ms\n",
      "Wall time: 13.3 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  36.32,  36.65, ..., 3095.69, 3123.50, 3151.57],\n",
       "       [ 35.36,  35.68,  36.00, ..., 3040.81, 3068.13, 3095.69],\n",
       "       [ 34.73,  35.05,  35.36, ..., 2986.89, 3013.73, 3040.81],\n",
       "       ...,\n",
       "       [  0.00,   0.00,   0.00, ...,   0.42,   0.42,   0.43],\n",
       "       [  0.00,   0.00,   0.00, ...,   0.41,   0.41,   0.42],\n",
       "       [  0.00,   0.00,   0.00, ...,   0.40,   0.41,   0.41]])"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time simulate_tree_np(500)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Numba"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [],
   "source": [
    "simulate_tree_nb = numba.jit(simulate_tree)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  39.79,  43.97,  48.59,  53.71],\n",
       "       [  0.00,  32.57,  36.00,  39.79,  43.97],\n",
       "       [  0.00,   0.00,  29.47,  32.57,  36.00],\n",
       "       [  0.00,   0.00,   0.00,  26.67,  29.47],\n",
       "       [  0.00,   0.00,   0.00,   0.00,  24.13]])"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simulate_tree_nb(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 945 µs, sys: 2.01 ms, total: 2.95 ms\n",
      "Wall time: 2.97 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  36.32,  36.65, ..., 3095.69, 3123.50, 3151.57],\n",
       "       [  0.00,  35.68,  36.00, ..., 3040.81, 3068.13, 3095.69],\n",
       "       [  0.00,   0.00,  35.36, ..., 2986.89, 3013.73, 3040.81],\n",
       "       ...,\n",
       "       [  0.00,   0.00,   0.00, ...,   0.42,   0.42,   0.43],\n",
       "       [  0.00,   0.00,   0.00, ...,   0.00,   0.41,   0.42],\n",
       "       [  0.00,   0.00,   0.00, ...,   0.00,   0.00,   0.41]])"
      ]
     },
     "execution_count": 114,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time simulate_tree_nb(500)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "258 µs ± 9.81 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit simulate_tree_nb(500)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cython"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<!DOCTYPE html>\n",
       "<!-- Generated by Cython 0.29.24 -->\n",
       "<html>\n",
       "<head>\n",
       "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n",
       "    <title>Cython: _cython_magic_504d9eb13b0cc195f4d1acdc76c921ca.pyx</title>\n",
       "    <style type=\"text/css\">\n",
       "    \n",
       "body.cython { font-family: courier; font-size: 12; }\n",
       "\n",
       ".cython.tag  {  }\n",
       ".cython.line { margin: 0em }\n",
       ".cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; }\n",
       "\n",
       ".cython.line .run { background-color: #B0FFB0; }\n",
       ".cython.line .mis { background-color: #FFB0B0; }\n",
       ".cython.code.run  { border-left: 8px solid #B0FFB0; }\n",
       ".cython.code.mis  { border-left: 8px solid #FFB0B0; }\n",
       "\n",
       ".cython.code .py_c_api  { color: red; }\n",
       ".cython.code .py_macro_api  { color: #FF7000; }\n",
       ".cython.code .pyx_c_api  { color: #FF3000; }\n",
       ".cython.code .pyx_macro_api  { color: #FF7000; }\n",
       ".cython.code .refnanny  { color: #FFA000; }\n",
       ".cython.code .trace  { color: #FFA000; }\n",
       ".cython.code .error_goto  { color: #FFA000; }\n",
       "\n",
       ".cython.code .coerce  { color: #008000; border: 1px dotted #008000 }\n",
       ".cython.code .py_attr { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_attr  { color: #0000FF; }\n",
       ".cython.code .py_call { color: #FF0000; font-weight: bold; }\n",
       ".cython.code .c_call  { color: #0000FF; }\n",
       "\n",
       ".cython.score-0 {background-color: #FFFFff;}\n",
       ".cython.score-1 {background-color: #FFFFe7;}\n",
       ".cython.score-2 {background-color: #FFFFd4;}\n",
       ".cython.score-3 {background-color: #FFFFc4;}\n",
       ".cython.score-4 {background-color: #FFFFb6;}\n",
       ".cython.score-5 {background-color: #FFFFaa;}\n",
       ".cython.score-6 {background-color: #FFFF9f;}\n",
       ".cython.score-7 {background-color: #FFFF96;}\n",
       ".cython.score-8 {background-color: #FFFF8d;}\n",
       ".cython.score-9 {background-color: #FFFF86;}\n",
       ".cython.score-10 {background-color: #FFFF7f;}\n",
       ".cython.score-11 {background-color: #FFFF79;}\n",
       ".cython.score-12 {background-color: #FFFF73;}\n",
       ".cython.score-13 {background-color: #FFFF6e;}\n",
       ".cython.score-14 {background-color: #FFFF6a;}\n",
       ".cython.score-15 {background-color: #FFFF66;}\n",
       ".cython.score-16 {background-color: #FFFF62;}\n",
       ".cython.score-17 {background-color: #FFFF5e;}\n",
       ".cython.score-18 {background-color: #FFFF5b;}\n",
       ".cython.score-19 {background-color: #FFFF57;}\n",
       ".cython.score-20 {background-color: #FFFF55;}\n",
       ".cython.score-21 {background-color: #FFFF52;}\n",
       ".cython.score-22 {background-color: #FFFF4f;}\n",
       ".cython.score-23 {background-color: #FFFF4d;}\n",
       ".cython.score-24 {background-color: #FFFF4b;}\n",
       ".cython.score-25 {background-color: #FFFF48;}\n",
       ".cython.score-26 {background-color: #FFFF46;}\n",
       ".cython.score-27 {background-color: #FFFF44;}\n",
       ".cython.score-28 {background-color: #FFFF43;}\n",
       ".cython.score-29 {background-color: #FFFF41;}\n",
       ".cython.score-30 {background-color: #FFFF3f;}\n",
       ".cython.score-31 {background-color: #FFFF3e;}\n",
       ".cython.score-32 {background-color: #FFFF3c;}\n",
       ".cython.score-33 {background-color: #FFFF3b;}\n",
       ".cython.score-34 {background-color: #FFFF39;}\n",
       ".cython.score-35 {background-color: #FFFF38;}\n",
       ".cython.score-36 {background-color: #FFFF37;}\n",
       ".cython.score-37 {background-color: #FFFF36;}\n",
       ".cython.score-38 {background-color: #FFFF35;}\n",
       ".cython.score-39 {background-color: #FFFF34;}\n",
       ".cython.score-40 {background-color: #FFFF33;}\n",
       ".cython.score-41 {background-color: #FFFF32;}\n",
       ".cython.score-42 {background-color: #FFFF31;}\n",
       ".cython.score-43 {background-color: #FFFF30;}\n",
       ".cython.score-44 {background-color: #FFFF2f;}\n",
       ".cython.score-45 {background-color: #FFFF2e;}\n",
       ".cython.score-46 {background-color: #FFFF2d;}\n",
       ".cython.score-47 {background-color: #FFFF2c;}\n",
       ".cython.score-48 {background-color: #FFFF2b;}\n",
       ".cython.score-49 {background-color: #FFFF2b;}\n",
       ".cython.score-50 {background-color: #FFFF2a;}\n",
       ".cython.score-51 {background-color: #FFFF29;}\n",
       ".cython.score-52 {background-color: #FFFF29;}\n",
       ".cython.score-53 {background-color: #FFFF28;}\n",
       ".cython.score-54 {background-color: #FFFF27;}\n",
       ".cython.score-55 {background-color: #FFFF27;}\n",
       ".cython.score-56 {background-color: #FFFF26;}\n",
       ".cython.score-57 {background-color: #FFFF26;}\n",
       ".cython.score-58 {background-color: #FFFF25;}\n",
       ".cython.score-59 {background-color: #FFFF24;}\n",
       ".cython.score-60 {background-color: #FFFF24;}\n",
       ".cython.score-61 {background-color: #FFFF23;}\n",
       ".cython.score-62 {background-color: #FFFF23;}\n",
       ".cython.score-63 {background-color: #FFFF22;}\n",
       ".cython.score-64 {background-color: #FFFF22;}\n",
       ".cython.score-65 {background-color: #FFFF22;}\n",
       ".cython.score-66 {background-color: #FFFF21;}\n",
       ".cython.score-67 {background-color: #FFFF21;}\n",
       ".cython.score-68 {background-color: #FFFF20;}\n",
       ".cython.score-69 {background-color: #FFFF20;}\n",
       ".cython.score-70 {background-color: #FFFF1f;}\n",
       ".cython.score-71 {background-color: #FFFF1f;}\n",
       ".cython.score-72 {background-color: #FFFF1f;}\n",
       ".cython.score-73 {background-color: #FFFF1e;}\n",
       ".cython.score-74 {background-color: #FFFF1e;}\n",
       ".cython.score-75 {background-color: #FFFF1e;}\n",
       ".cython.score-76 {background-color: #FFFF1d;}\n",
       ".cython.score-77 {background-color: #FFFF1d;}\n",
       ".cython.score-78 {background-color: #FFFF1c;}\n",
       ".cython.score-79 {background-color: #FFFF1c;}\n",
       ".cython.score-80 {background-color: #FFFF1c;}\n",
       ".cython.score-81 {background-color: #FFFF1c;}\n",
       ".cython.score-82 {background-color: #FFFF1b;}\n",
       ".cython.score-83 {background-color: #FFFF1b;}\n",
       ".cython.score-84 {background-color: #FFFF1b;}\n",
       ".cython.score-85 {background-color: #FFFF1a;}\n",
       ".cython.score-86 {background-color: #FFFF1a;}\n",
       ".cython.score-87 {background-color: #FFFF1a;}\n",
       ".cython.score-88 {background-color: #FFFF1a;}\n",
       ".cython.score-89 {background-color: #FFFF19;}\n",
       ".cython.score-90 {background-color: #FFFF19;}\n",
       ".cython.score-91 {background-color: #FFFF19;}\n",
       ".cython.score-92 {background-color: #FFFF19;}\n",
       ".cython.score-93 {background-color: #FFFF18;}\n",
       ".cython.score-94 {background-color: #FFFF18;}\n",
       ".cython.score-95 {background-color: #FFFF18;}\n",
       ".cython.score-96 {background-color: #FFFF18;}\n",
       ".cython.score-97 {background-color: #FFFF17;}\n",
       ".cython.score-98 {background-color: #FFFF17;}\n",
       ".cython.score-99 {background-color: #FFFF17;}\n",
       ".cython.score-100 {background-color: #FFFF17;}\n",
       ".cython.score-101 {background-color: #FFFF16;}\n",
       ".cython.score-102 {background-color: #FFFF16;}\n",
       ".cython.score-103 {background-color: #FFFF16;}\n",
       ".cython.score-104 {background-color: #FFFF16;}\n",
       ".cython.score-105 {background-color: #FFFF16;}\n",
       ".cython.score-106 {background-color: #FFFF15;}\n",
       ".cython.score-107 {background-color: #FFFF15;}\n",
       ".cython.score-108 {background-color: #FFFF15;}\n",
       ".cython.score-109 {background-color: #FFFF15;}\n",
       ".cython.score-110 {background-color: #FFFF15;}\n",
       ".cython.score-111 {background-color: #FFFF15;}\n",
       ".cython.score-112 {background-color: #FFFF14;}\n",
       ".cython.score-113 {background-color: #FFFF14;}\n",
       ".cython.score-114 {background-color: #FFFF14;}\n",
       ".cython.score-115 {background-color: #FFFF14;}\n",
       ".cython.score-116 {background-color: #FFFF14;}\n",
       ".cython.score-117 {background-color: #FFFF14;}\n",
       ".cython.score-118 {background-color: #FFFF13;}\n",
       ".cython.score-119 {background-color: #FFFF13;}\n",
       ".cython.score-120 {background-color: #FFFF13;}\n",
       ".cython.score-121 {background-color: #FFFF13;}\n",
       ".cython.score-122 {background-color: #FFFF13;}\n",
       ".cython.score-123 {background-color: #FFFF13;}\n",
       ".cython.score-124 {background-color: #FFFF13;}\n",
       ".cython.score-125 {background-color: #FFFF12;}\n",
       ".cython.score-126 {background-color: #FFFF12;}\n",
       ".cython.score-127 {background-color: #FFFF12;}\n",
       ".cython.score-128 {background-color: #FFFF12;}\n",
       ".cython.score-129 {background-color: #FFFF12;}\n",
       ".cython.score-130 {background-color: #FFFF12;}\n",
       ".cython.score-131 {background-color: #FFFF12;}\n",
       ".cython.score-132 {background-color: #FFFF11;}\n",
       ".cython.score-133 {background-color: #FFFF11;}\n",
       ".cython.score-134 {background-color: #FFFF11;}\n",
       ".cython.score-135 {background-color: #FFFF11;}\n",
       ".cython.score-136 {background-color: #FFFF11;}\n",
       ".cython.score-137 {background-color: #FFFF11;}\n",
       ".cython.score-138 {background-color: #FFFF11;}\n",
       ".cython.score-139 {background-color: #FFFF11;}\n",
       ".cython.score-140 {background-color: #FFFF11;}\n",
       ".cython.score-141 {background-color: #FFFF10;}\n",
       ".cython.score-142 {background-color: #FFFF10;}\n",
       ".cython.score-143 {background-color: #FFFF10;}\n",
       ".cython.score-144 {background-color: #FFFF10;}\n",
       ".cython.score-145 {background-color: #FFFF10;}\n",
       ".cython.score-146 {background-color: #FFFF10;}\n",
       ".cython.score-147 {background-color: #FFFF10;}\n",
       ".cython.score-148 {background-color: #FFFF10;}\n",
       ".cython.score-149 {background-color: #FFFF10;}\n",
       ".cython.score-150 {background-color: #FFFF0f;}\n",
       ".cython.score-151 {background-color: #FFFF0f;}\n",
       ".cython.score-152 {background-color: #FFFF0f;}\n",
       ".cython.score-153 {background-color: #FFFF0f;}\n",
       ".cython.score-154 {background-color: #FFFF0f;}\n",
       ".cython.score-155 {background-color: #FFFF0f;}\n",
       ".cython.score-156 {background-color: #FFFF0f;}\n",
       ".cython.score-157 {background-color: #FFFF0f;}\n",
       ".cython.score-158 {background-color: #FFFF0f;}\n",
       ".cython.score-159 {background-color: #FFFF0f;}\n",
       ".cython.score-160 {background-color: #FFFF0f;}\n",
       ".cython.score-161 {background-color: #FFFF0e;}\n",
       ".cython.score-162 {background-color: #FFFF0e;}\n",
       ".cython.score-163 {background-color: #FFFF0e;}\n",
       ".cython.score-164 {background-color: #FFFF0e;}\n",
       ".cython.score-165 {background-color: #FFFF0e;}\n",
       ".cython.score-166 {background-color: #FFFF0e;}\n",
       ".cython.score-167 {background-color: #FFFF0e;}\n",
       ".cython.score-168 {background-color: #FFFF0e;}\n",
       ".cython.score-169 {background-color: #FFFF0e;}\n",
       ".cython.score-170 {background-color: #FFFF0e;}\n",
       ".cython.score-171 {background-color: #FFFF0e;}\n",
       ".cython.score-172 {background-color: #FFFF0e;}\n",
       ".cython.score-173 {background-color: #FFFF0d;}\n",
       ".cython.score-174 {background-color: #FFFF0d;}\n",
       ".cython.score-175 {background-color: #FFFF0d;}\n",
       ".cython.score-176 {background-color: #FFFF0d;}\n",
       ".cython.score-177 {background-color: #FFFF0d;}\n",
       ".cython.score-178 {background-color: #FFFF0d;}\n",
       ".cython.score-179 {background-color: #FFFF0d;}\n",
       ".cython.score-180 {background-color: #FFFF0d;}\n",
       ".cython.score-181 {background-color: #FFFF0d;}\n",
       ".cython.score-182 {background-color: #FFFF0d;}\n",
       ".cython.score-183 {background-color: #FFFF0d;}\n",
       ".cython.score-184 {background-color: #FFFF0d;}\n",
       ".cython.score-185 {background-color: #FFFF0d;}\n",
       ".cython.score-186 {background-color: #FFFF0d;}\n",
       ".cython.score-187 {background-color: #FFFF0c;}\n",
       ".cython.score-188 {background-color: #FFFF0c;}\n",
       ".cython.score-189 {background-color: #FFFF0c;}\n",
       ".cython.score-190 {background-color: #FFFF0c;}\n",
       ".cython.score-191 {background-color: #FFFF0c;}\n",
       ".cython.score-192 {background-color: #FFFF0c;}\n",
       ".cython.score-193 {background-color: #FFFF0c;}\n",
       ".cython.score-194 {background-color: #FFFF0c;}\n",
       ".cython.score-195 {background-color: #FFFF0c;}\n",
       ".cython.score-196 {background-color: #FFFF0c;}\n",
       ".cython.score-197 {background-color: #FFFF0c;}\n",
       ".cython.score-198 {background-color: #FFFF0c;}\n",
       ".cython.score-199 {background-color: #FFFF0c;}\n",
       ".cython.score-200 {background-color: #FFFF0c;}\n",
       ".cython.score-201 {background-color: #FFFF0c;}\n",
       ".cython.score-202 {background-color: #FFFF0c;}\n",
       ".cython.score-203 {background-color: #FFFF0b;}\n",
       ".cython.score-204 {background-color: #FFFF0b;}\n",
       ".cython.score-205 {background-color: #FFFF0b;}\n",
       ".cython.score-206 {background-color: #FFFF0b;}\n",
       ".cython.score-207 {background-color: #FFFF0b;}\n",
       ".cython.score-208 {background-color: #FFFF0b;}\n",
       ".cython.score-209 {background-color: #FFFF0b;}\n",
       ".cython.score-210 {background-color: #FFFF0b;}\n",
       ".cython.score-211 {background-color: #FFFF0b;}\n",
       ".cython.score-212 {background-color: #FFFF0b;}\n",
       ".cython.score-213 {background-color: #FFFF0b;}\n",
       ".cython.score-214 {background-color: #FFFF0b;}\n",
       ".cython.score-215 {background-color: #FFFF0b;}\n",
       ".cython.score-216 {background-color: #FFFF0b;}\n",
       ".cython.score-217 {background-color: #FFFF0b;}\n",
       ".cython.score-218 {background-color: #FFFF0b;}\n",
       ".cython.score-219 {background-color: #FFFF0b;}\n",
       ".cython.score-220 {background-color: #FFFF0b;}\n",
       ".cython.score-221 {background-color: #FFFF0b;}\n",
       ".cython.score-222 {background-color: #FFFF0a;}\n",
       ".cython.score-223 {background-color: #FFFF0a;}\n",
       ".cython.score-224 {background-color: #FFFF0a;}\n",
       ".cython.score-225 {background-color: #FFFF0a;}\n",
       ".cython.score-226 {background-color: #FFFF0a;}\n",
       ".cython.score-227 {background-color: #FFFF0a;}\n",
       ".cython.score-228 {background-color: #FFFF0a;}\n",
       ".cython.score-229 {background-color: #FFFF0a;}\n",
       ".cython.score-230 {background-color: #FFFF0a;}\n",
       ".cython.score-231 {background-color: #FFFF0a;}\n",
       ".cython.score-232 {background-color: #FFFF0a;}\n",
       ".cython.score-233 {background-color: #FFFF0a;}\n",
       ".cython.score-234 {background-color: #FFFF0a;}\n",
       ".cython.score-235 {background-color: #FFFF0a;}\n",
       ".cython.score-236 {background-color: #FFFF0a;}\n",
       ".cython.score-237 {background-color: #FFFF0a;}\n",
       ".cython.score-238 {background-color: #FFFF0a;}\n",
       ".cython.score-239 {background-color: #FFFF0a;}\n",
       ".cython.score-240 {background-color: #FFFF0a;}\n",
       ".cython.score-241 {background-color: #FFFF0a;}\n",
       ".cython.score-242 {background-color: #FFFF0a;}\n",
       ".cython.score-243 {background-color: #FFFF0a;}\n",
       ".cython.score-244 {background-color: #FFFF0a;}\n",
       ".cython.score-245 {background-color: #FFFF0a;}\n",
       ".cython.score-246 {background-color: #FFFF09;}\n",
       ".cython.score-247 {background-color: #FFFF09;}\n",
       ".cython.score-248 {background-color: #FFFF09;}\n",
       ".cython.score-249 {background-color: #FFFF09;}\n",
       ".cython.score-250 {background-color: #FFFF09;}\n",
       ".cython.score-251 {background-color: #FFFF09;}\n",
       ".cython.score-252 {background-color: #FFFF09;}\n",
       ".cython.score-253 {background-color: #FFFF09;}\n",
       ".cython.score-254 {background-color: #FFFF09;}\n",
       "pre { line-height: 125%; }\n",
       "td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\n",
       "td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       "span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n",
       ".cython .hll { background-color: #ffffcc }\n",
       ".cython { background: #f8f8f8; }\n",
       ".cython .c { color: #408080; font-style: italic } /* Comment */\n",
       ".cython .err { border: 1px solid #FF0000 } /* Error */\n",
       ".cython .k { color: #008000; font-weight: bold } /* Keyword */\n",
       ".cython .o { color: #666666 } /* Operator */\n",
       ".cython .ch { color: #408080; font-style: italic } /* Comment.Hashbang */\n",
       ".cython .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n",
       ".cython .cp { color: #BC7A00 } /* Comment.Preproc */\n",
       ".cython .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */\n",
       ".cython .c1 { color: #408080; font-style: italic } /* Comment.Single */\n",
       ".cython .cs { color: #408080; font-style: italic } /* Comment.Special */\n",
       ".cython .gd { color: #A00000 } /* Generic.Deleted */\n",
       ".cython .ge { font-style: italic } /* Generic.Emph */\n",
       ".cython .gr { color: #FF0000 } /* Generic.Error */\n",
       ".cython .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n",
       ".cython .gi { color: #00A000 } /* Generic.Inserted */\n",
       ".cython .go { color: #888888 } /* Generic.Output */\n",
       ".cython .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n",
       ".cython .gs { font-weight: bold } /* Generic.Strong */\n",
       ".cython .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n",
       ".cython .gt { color: #0044DD } /* Generic.Traceback */\n",
       ".cython .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n",
       ".cython .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n",
       ".cython .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n",
       ".cython .kp { color: #008000 } /* Keyword.Pseudo */\n",
       ".cython .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n",
       ".cython .kt { color: #B00040 } /* Keyword.Type */\n",
       ".cython .m { color: #666666 } /* Literal.Number */\n",
       ".cython .s { color: #BA2121 } /* Literal.String */\n",
       ".cython .na { color: #7D9029 } /* Name.Attribute */\n",
       ".cython .nb { color: #008000 } /* Name.Builtin */\n",
       ".cython .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n",
       ".cython .no { color: #880000 } /* Name.Constant */\n",
       ".cython .nd { color: #AA22FF } /* Name.Decorator */\n",
       ".cython .ni { color: #999999; font-weight: bold } /* Name.Entity */\n",
       ".cython .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n",
       ".cython .nf { color: #0000FF } /* Name.Function */\n",
       ".cython .nl { color: #A0A000 } /* Name.Label */\n",
       ".cython .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n",
       ".cython .nt { color: #008000; font-weight: bold } /* Name.Tag */\n",
       ".cython .nv { color: #19177C } /* Name.Variable */\n",
       ".cython .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n",
       ".cython .w { color: #bbbbbb } /* Text.Whitespace */\n",
       ".cython .mb { color: #666666 } /* Literal.Number.Bin */\n",
       ".cython .mf { color: #666666 } /* Literal.Number.Float */\n",
       ".cython .mh { color: #666666 } /* Literal.Number.Hex */\n",
       ".cython .mi { color: #666666 } /* Literal.Number.Integer */\n",
       ".cython .mo { color: #666666 } /* Literal.Number.Oct */\n",
       ".cython .sa { color: #BA2121 } /* Literal.String.Affix */\n",
       ".cython .sb { color: #BA2121 } /* Literal.String.Backtick */\n",
       ".cython .sc { color: #BA2121 } /* Literal.String.Char */\n",
       ".cython .dl { color: #BA2121 } /* Literal.String.Delimiter */\n",
       ".cython .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n",
       ".cython .s2 { color: #BA2121 } /* Literal.String.Double */\n",
       ".cython .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n",
       ".cython .sh { color: #BA2121 } /* Literal.String.Heredoc */\n",
       ".cython .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n",
       ".cython .sx { color: #008000 } /* Literal.String.Other */\n",
       ".cython .sr { color: #BB6688 } /* Literal.String.Regex */\n",
       ".cython .s1 { color: #BA2121 } /* Literal.String.Single */\n",
       ".cython .ss { color: #19177C } /* Literal.String.Symbol */\n",
       ".cython .bp { color: #008000 } /* Name.Builtin.Pseudo */\n",
       ".cython .fm { color: #0000FF } /* Name.Function.Magic */\n",
       ".cython .vc { color: #19177C } /* Name.Variable.Class */\n",
       ".cython .vg { color: #19177C } /* Name.Variable.Global */\n",
       ".cython .vi { color: #19177C } /* Name.Variable.Instance */\n",
       ".cython .vm { color: #19177C } /* Name.Variable.Magic */\n",
       ".cython .il { color: #666666 } /* Literal.Number.Integer.Long */\n",
       "    </style>\n",
       "</head>\n",
       "<body class=\"cython\">\n",
       "<p><span style=\"border-bottom: solid 1px grey;\">Generated by Cython 0.29.24</span></p>\n",
       "<p>\n",
       "    <span style=\"background-color: #FFFF00\">Yellow lines</span> hint at Python interaction.<br />\n",
       "    Click on a line that starts with a \"<code>+</code>\" to see the C code that Cython generated for it.\n",
       "</p>\n",
       "<div class=\"cython\"><pre class=\"cython line score-16\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">01</span>: <span class=\"k\">import</span> <span class=\"nn\">numpy</span> <span class=\"k\">as</span> <span class=\"nn\">np</span></pre>\n",
       "<pre class='cython code score-16 '>  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_Import</span>(__pyx_n_s_numpy, 0, 0);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_np, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 1, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "/* … */\n",
       "  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyDict_NewPresized</span>(0);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_test, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 1, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "</pre><pre class=\"cython line score-0\">&#xA0;<span class=\"\">02</span>: <span class=\"k\">cimport</span> <span class=\"nn\">cython</span></pre>\n",
       "<pre class=\"cython line score-0\">&#xA0;<span class=\"\">03</span>: <span class=\"k\">from</span> <span class=\"nn\">libc.math</span> <span class=\"k\">cimport</span> <span class=\"n\">exp</span><span class=\"p\">,</span> <span class=\"n\">sqrt</span></pre>\n",
       "<pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">04</span>: <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">S0</span> <span class=\"o\">=</span> <span class=\"mf\">36.</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_S0 = 36.;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">05</span>: <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">T</span> <span class=\"o\">=</span> <span class=\"mf\">1.0</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_T = 1.0;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">06</span>: <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">r</span> <span class=\"o\">=</span> <span class=\"mf\">0.06</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_r = 0.06;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">07</span>: <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">sigma</span> <span class=\"o\">=</span> <span class=\"mf\">0.2</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_sigma = 0.2;\n",
       "</pre><pre class=\"cython line score-29\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">08</span>: <span class=\"k\">def</span> <span class=\"nf\">simulate_tree_cy</span><span class=\"p\">(</span><span class=\"nb\">int</span> <span class=\"n\">M</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-29 '>/* Python wrapper */\n",
       "static PyObject *__pyx_pw_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_1simulate_tree_cy(PyObject *__pyx_self, PyObject *__pyx_arg_M); /*proto*/\n",
       "static PyMethodDef __pyx_mdef_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_1simulate_tree_cy = {\"simulate_tree_cy\", (PyCFunction)__pyx_pw_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_1simulate_tree_cy, METH_O, 0};\n",
       "static PyObject *__pyx_pw_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_1simulate_tree_cy(PyObject *__pyx_self, PyObject *__pyx_arg_M) {\n",
       "  int __pyx_v_M;\n",
       "  PyObject *__pyx_r = 0;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"simulate_tree_cy (wrapper)\", 0);\n",
       "  assert(__pyx_arg_M); {\n",
       "    __pyx_v_M = <span class='pyx_c_api'>__Pyx_PyInt_As_int</span>(__pyx_arg_M); if (unlikely((__pyx_v_M == (int)-1) &amp;&amp; <span class='py_c_api'>PyErr_Occurred</span>())) <span class='error_goto'>__PYX_ERR(0, 8, __pyx_L3_error)</span>\n",
       "  }\n",
       "  goto __pyx_L4_argument_unpacking_done;\n",
       "  __pyx_L3_error:;\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca.simulate_tree_cy\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return NULL;\n",
       "  __pyx_L4_argument_unpacking_done:;\n",
       "  __pyx_r = __pyx_pf_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_simulate_tree_cy(__pyx_self, ((int)__pyx_v_M));\n",
       "  int __pyx_lineno = 0;\n",
       "  const char *__pyx_filename = NULL;\n",
       "  int __pyx_clineno = 0;\n",
       "\n",
       "  /* function exit code */\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "\n",
       "static PyObject *__pyx_pf_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_simulate_tree_cy(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_M) {\n",
       "  int __pyx_v_z;\n",
       "  int __pyx_v_t;\n",
       "  int __pyx_v_i;\n",
       "  float __pyx_v_dt;\n",
       "  float __pyx_v_u;\n",
       "  float __pyx_v_d;\n",
       "  __Pyx_memviewslice __pyx_v_S = { 0, 0, { 0 }, { 0 }, { 0 } };\n",
       "  PyObject *__pyx_r = NULL;\n",
       "  <span class='refnanny'>__Pyx_RefNannyDeclarations</span>\n",
       "  <span class='refnanny'>__Pyx_RefNannySetupContext</span>(\"simulate_tree_cy\", 0);\n",
       "/* … */\n",
       "  /* function exit code */\n",
       "  __pyx_L1_error:;\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_1);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_3);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_4);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_5);\n",
       "  __PYX_XDEC_MEMVIEW(&amp;__pyx_t_6, 1);\n",
       "  <span class='pyx_c_api'>__Pyx_AddTraceback</span>(\"_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca.simulate_tree_cy\", __pyx_clineno, __pyx_lineno, __pyx_filename);\n",
       "  __pyx_r = NULL;\n",
       "  __pyx_L0:;\n",
       "  __PYX_XDEC_MEMVIEW(&amp;__pyx_v_S, 1);\n",
       "  <span class='refnanny'>__Pyx_XGIVEREF</span>(__pyx_r);\n",
       "  <span class='refnanny'>__Pyx_RefNannyFinishContext</span>();\n",
       "  return __pyx_r;\n",
       "}\n",
       "/* … */\n",
       "  __pyx_tuple__19 = <span class='py_c_api'>PyTuple_Pack</span>(9, __pyx_n_s_M, __pyx_n_s_M, __pyx_n_s_z, __pyx_n_s_t, __pyx_n_s_i, __pyx_n_s_dt, __pyx_n_s_u, __pyx_n_s_d, __pyx_n_s_S);<span class='error_goto'> if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 8, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_tuple__19);\n",
       "  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_tuple__19);\n",
       "/* … */\n",
       "  __pyx_t_1 = PyCFunction_NewEx(&amp;__pyx_mdef_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_1simulate_tree_cy, NULL, __pyx_n_s_cython_magic_504d9eb13b0cc195f4);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_d, __pyx_n_s_simulate_tree_cy, __pyx_t_1) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 8, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "  __pyx_codeobj__20 = (PyObject*)<span class='pyx_c_api'>__Pyx_PyCode_New</span>(1, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_yves_ipython_cython__cyth, __pyx_n_s_simulate_tree_cy, 8, __pyx_empty_bytes);<span class='error_goto'> if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 8, __pyx_L1_error)</span>\n",
       "</pre><pre class=\"cython line score-0\">&#xA0;<span class=\"\">09</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">int</span> <span class=\"nf\">z</span><span class=\"p\">,</span> <span class=\"nf\">t</span><span class=\"p\">,</span> <span class=\"nf\">i</span></pre>\n",
       "<pre class=\"cython line score-0\">&#xA0;<span class=\"\">10</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">float</span> <span class=\"nf\">dt</span><span class=\"p\">,</span> <span class=\"nf\">u</span><span class=\"p\">,</span> <span class=\"nf\">d</span></pre>\n",
       "<pre class=\"cython line score-30\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">11</span>:     <span class=\"k\">cdef</span> <span class=\"kt\">float</span>[<span class=\"p\">:,</span> <span class=\"p\">:]</span> <span class=\"n\">S</span> <span class=\"o\">=</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">zeros</span><span class=\"p\">((</span><span class=\"n\">M</span> <span class=\"o\">+</span> <span class=\"mf\">1</span><span class=\"p\">,</span> <span class=\"n\">M</span> <span class=\"o\">+</span> <span class=\"mf\">1</span><span class=\"p\">),</span></pre>\n",
       "<pre class='cython code score-30 '>  <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_1, __pyx_n_s_np);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  __pyx_t_2 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_zeros);<span class='error_goto'> if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_2);\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "  __pyx_t_1 = <span class='pyx_c_api'>__Pyx_PyInt_From_long</span>((__pyx_v_M + 1));<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyInt_From_long</span>((__pyx_v_M + 1));<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);\n",
       "  __pyx_t_4 = <span class='py_c_api'>PyTuple_New</span>(2);<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);\n",
       "  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_1);\n",
       "  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 0, __pyx_t_1);\n",
       "  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_3);\n",
       "  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_4, 1, __pyx_t_3);\n",
       "  __pyx_t_1 = 0;\n",
       "  __pyx_t_3 = 0;\n",
       "  __pyx_t_3 = <span class='py_c_api'>PyTuple_New</span>(1);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);\n",
       "  <span class='refnanny'>__Pyx_GIVEREF</span>(__pyx_t_4);\n",
       "  <span class='py_macro_api'>PyTuple_SET_ITEM</span>(__pyx_t_3, 0, __pyx_t_4);\n",
       "  __pyx_t_4 = 0;\n",
       "/* … */\n",
       "  __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_Call</span>(__pyx_t_2, __pyx_t_3, __pyx_t_4);<span class='error_goto'> if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_2); __pyx_t_2 = 0;\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;\n",
       "  __pyx_t_6 = <span class='pyx_c_api'>__Pyx_PyObject_to_MemoryviewSlice_dsds_float</span>(__pyx_t_5, PyBUF_WRITABLE);<span class='error_goto'> if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 11, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;\n",
       "  __pyx_v_S = __pyx_t_6;\n",
       "  __pyx_t_6.memview = NULL;\n",
       "  __pyx_t_6.data = NULL;\n",
       "</pre><pre class=\"cython line score-13\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">12</span>:                                   <span class=\"n\">dtype</span><span class=\"o\">=</span><span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">float32</span><span class=\"p\">)</span></pre>\n",
       "<pre class='cython code score-13 '>  __pyx_t_4 = <span class='pyx_c_api'>__Pyx_PyDict_NewPresized</span>(1);<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 12, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);\n",
       "  <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_1, __pyx_n_s_np);<span class='error_goto'> if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_1);\n",
       "  __pyx_t_5 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_1, __pyx_n_s_float32);<span class='error_goto'> if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 12, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_1); __pyx_t_1 = 0;\n",
       "  if (<span class='py_c_api'>PyDict_SetItem</span>(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_5) &lt; 0) <span class='error_goto'>__PYX_ERR(0, 12, __pyx_L1_error)</span>\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_5); __pyx_t_5 = 0;\n",
       "</pre><pre class=\"cython line score-5\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">13</span>:     <span class=\"n\">dt</span> <span class=\"o\">=</span> <span class=\"n\">T</span> <span class=\"o\">/</span> <span class=\"n\">M</span></pre>\n",
       "<pre class='cython code score-5 '>  if (unlikely(__pyx_v_M == 0)) {\n",
       "    <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "    <span class='error_goto'>__PYX_ERR(0, 13, __pyx_L1_error)</span>\n",
       "  }\n",
       "  __pyx_v_dt = (__pyx_v_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_T / ((float)__pyx_v_M));\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">14</span>:     <span class=\"n\">u</span> <span class=\"o\">=</span> <span class=\"n\">exp</span><span class=\"p\">(</span><span class=\"n\">sigma</span> <span class=\"o\">*</span> <span class=\"n\">sqrt</span><span class=\"p\">(</span><span class=\"n\">dt</span><span class=\"p\">))</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_u = exp((__pyx_v_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_sigma * sqrt(__pyx_v_dt)));\n",
       "</pre><pre class=\"cython line score-5\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">15</span>:     <span class=\"n\">d</span> <span class=\"o\">=</span> <span class=\"mf\">1</span> <span class=\"o\">/</span> <span class=\"n\">u</span></pre>\n",
       "<pre class='cython code score-5 '>  if (unlikely(__pyx_v_u == 0)) {\n",
       "    <span class='py_c_api'>PyErr_SetString</span>(PyExc_ZeroDivisionError, \"float division\");\n",
       "    <span class='error_goto'>__PYX_ERR(0, 15, __pyx_L1_error)</span>\n",
       "  }\n",
       "  __pyx_v_d = (1.0 / __pyx_v_u);\n",
       "</pre><pre class=\"cython line score-2\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">16</span>:     <span class=\"n\">S</span><span class=\"p\">[</span><span class=\"mf\">0</span><span class=\"p\">,</span> <span class=\"mf\">0</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"n\">S0</span></pre>\n",
       "<pre class='cython code score-2 '>  __pyx_t_7 = 0;\n",
       "  __pyx_t_8 = 0;\n",
       "  __pyx_t_9 = -1;\n",
       "  if (__pyx_t_7 &lt; 0) {\n",
       "    __pyx_t_7 += __pyx_v_S.shape[0];\n",
       "    if (unlikely(__pyx_t_7 &lt; 0)) __pyx_t_9 = 0;\n",
       "  } else if (unlikely(__pyx_t_7 &gt;= __pyx_v_S.shape[0])) __pyx_t_9 = 0;\n",
       "  if (__pyx_t_8 &lt; 0) {\n",
       "    __pyx_t_8 += __pyx_v_S.shape[1];\n",
       "    if (unlikely(__pyx_t_8 &lt; 0)) __pyx_t_9 = 1;\n",
       "  } else if (unlikely(__pyx_t_8 &gt;= __pyx_v_S.shape[1])) __pyx_t_9 = 1;\n",
       "  if (unlikely(__pyx_t_9 != -1)) {\n",
       "    <span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_9);\n",
       "    <span class='error_goto'>__PYX_ERR(0, 16, __pyx_L1_error)</span>\n",
       "  }\n",
       "  *((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_S.data + __pyx_t_7 * __pyx_v_S.strides[0]) ) + __pyx_t_8 * __pyx_v_S.strides[1]) )) = __pyx_v_46_cython_magic_504d9eb13b0cc195f4d1acdc76c921ca_S0;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">17</span>:     <span class=\"n\">z</span> <span class=\"o\">=</span> <span class=\"mf\">1</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_v_z = 1;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">18</span>:     <span class=\"k\">for</span> <span class=\"n\">t</span> <span class=\"ow\">in</span> <span class=\"nb\">range</span><span class=\"p\">(</span><span class=\"mf\">1</span><span class=\"p\">,</span> <span class=\"n\">M</span> <span class=\"o\">+</span> <span class=\"mf\">1</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-0 '>  __pyx_t_10 = (__pyx_v_M + 1);\n",
       "  __pyx_t_11 = __pyx_t_10;\n",
       "  for (__pyx_t_9 = 1; __pyx_t_9 &lt; __pyx_t_11; __pyx_t_9+=1) {\n",
       "    __pyx_v_t = __pyx_t_9;\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">19</span>:         <span class=\"k\">for</span> <span class=\"n\">i</span> <span class=\"ow\">in</span> <span class=\"nb\">range</span><span class=\"p\">(</span><span class=\"n\">z</span><span class=\"p\">):</span></pre>\n",
       "<pre class='cython code score-0 '>    __pyx_t_12 = __pyx_v_z;\n",
       "    __pyx_t_13 = __pyx_t_12;\n",
       "    for (__pyx_t_14 = 0; __pyx_t_14 &lt; __pyx_t_13; __pyx_t_14+=1) {\n",
       "      __pyx_v_i = __pyx_t_14;\n",
       "</pre><pre class=\"cython line score-4\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">20</span>:             <span class=\"n\">S</span><span class=\"p\">[</span><span class=\"n\">i</span><span class=\"p\">,</span> <span class=\"n\">t</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"n\">S</span><span class=\"p\">[</span><span class=\"n\">i</span><span class=\"p\">,</span> <span class=\"n\">t</span><span class=\"o\">-</span><span class=\"mf\">1</span><span class=\"p\">]</span> <span class=\"o\">*</span> <span class=\"n\">u</span></pre>\n",
       "<pre class='cython code score-4 '>      __pyx_t_8 = __pyx_v_i;\n",
       "      __pyx_t_7 = (__pyx_v_t - 1);\n",
       "      __pyx_t_15 = -1;\n",
       "      if (__pyx_t_8 &lt; 0) {\n",
       "        __pyx_t_8 += __pyx_v_S.shape[0];\n",
       "        if (unlikely(__pyx_t_8 &lt; 0)) __pyx_t_15 = 0;\n",
       "      } else if (unlikely(__pyx_t_8 &gt;= __pyx_v_S.shape[0])) __pyx_t_15 = 0;\n",
       "      if (__pyx_t_7 &lt; 0) {\n",
       "        __pyx_t_7 += __pyx_v_S.shape[1];\n",
       "        if (unlikely(__pyx_t_7 &lt; 0)) __pyx_t_15 = 1;\n",
       "      } else if (unlikely(__pyx_t_7 &gt;= __pyx_v_S.shape[1])) __pyx_t_15 = 1;\n",
       "      if (unlikely(__pyx_t_15 != -1)) {\n",
       "        <span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_15);\n",
       "        <span class='error_goto'>__PYX_ERR(0, 20, __pyx_L1_error)</span>\n",
       "      }\n",
       "      __pyx_t_16 = __pyx_v_i;\n",
       "      __pyx_t_17 = __pyx_v_t;\n",
       "      __pyx_t_15 = -1;\n",
       "      if (__pyx_t_16 &lt; 0) {\n",
       "        __pyx_t_16 += __pyx_v_S.shape[0];\n",
       "        if (unlikely(__pyx_t_16 &lt; 0)) __pyx_t_15 = 0;\n",
       "      } else if (unlikely(__pyx_t_16 &gt;= __pyx_v_S.shape[0])) __pyx_t_15 = 0;\n",
       "      if (__pyx_t_17 &lt; 0) {\n",
       "        __pyx_t_17 += __pyx_v_S.shape[1];\n",
       "        if (unlikely(__pyx_t_17 &lt; 0)) __pyx_t_15 = 1;\n",
       "      } else if (unlikely(__pyx_t_17 &gt;= __pyx_v_S.shape[1])) __pyx_t_15 = 1;\n",
       "      if (unlikely(__pyx_t_15 != -1)) {\n",
       "        <span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_15);\n",
       "        <span class='error_goto'>__PYX_ERR(0, 20, __pyx_L1_error)</span>\n",
       "      }\n",
       "      *((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_S.data + __pyx_t_16 * __pyx_v_S.strides[0]) ) + __pyx_t_17 * __pyx_v_S.strides[1]) )) = ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_S.data + __pyx_t_8 * __pyx_v_S.strides[0]) ) + __pyx_t_7 * __pyx_v_S.strides[1]) ))) * __pyx_v_u);\n",
       "</pre><pre class=\"cython line score-4\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">21</span>:             <span class=\"n\">S</span><span class=\"p\">[</span><span class=\"n\">i</span><span class=\"o\">+</span><span class=\"mf\">1</span><span class=\"p\">,</span> <span class=\"n\">t</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"n\">S</span><span class=\"p\">[</span><span class=\"n\">i</span><span class=\"p\">,</span> <span class=\"n\">t</span><span class=\"o\">-</span><span class=\"mf\">1</span><span class=\"p\">]</span> <span class=\"o\">*</span> <span class=\"n\">d</span></pre>\n",
       "<pre class='cython code score-4 '>      __pyx_t_7 = __pyx_v_i;\n",
       "      __pyx_t_8 = (__pyx_v_t - 1);\n",
       "      __pyx_t_15 = -1;\n",
       "      if (__pyx_t_7 &lt; 0) {\n",
       "        __pyx_t_7 += __pyx_v_S.shape[0];\n",
       "        if (unlikely(__pyx_t_7 &lt; 0)) __pyx_t_15 = 0;\n",
       "      } else if (unlikely(__pyx_t_7 &gt;= __pyx_v_S.shape[0])) __pyx_t_15 = 0;\n",
       "      if (__pyx_t_8 &lt; 0) {\n",
       "        __pyx_t_8 += __pyx_v_S.shape[1];\n",
       "        if (unlikely(__pyx_t_8 &lt; 0)) __pyx_t_15 = 1;\n",
       "      } else if (unlikely(__pyx_t_8 &gt;= __pyx_v_S.shape[1])) __pyx_t_15 = 1;\n",
       "      if (unlikely(__pyx_t_15 != -1)) {\n",
       "        <span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_15);\n",
       "        <span class='error_goto'>__PYX_ERR(0, 21, __pyx_L1_error)</span>\n",
       "      }\n",
       "      __pyx_t_17 = (__pyx_v_i + 1);\n",
       "      __pyx_t_16 = __pyx_v_t;\n",
       "      __pyx_t_15 = -1;\n",
       "      if (__pyx_t_17 &lt; 0) {\n",
       "        __pyx_t_17 += __pyx_v_S.shape[0];\n",
       "        if (unlikely(__pyx_t_17 &lt; 0)) __pyx_t_15 = 0;\n",
       "      } else if (unlikely(__pyx_t_17 &gt;= __pyx_v_S.shape[0])) __pyx_t_15 = 0;\n",
       "      if (__pyx_t_16 &lt; 0) {\n",
       "        __pyx_t_16 += __pyx_v_S.shape[1];\n",
       "        if (unlikely(__pyx_t_16 &lt; 0)) __pyx_t_15 = 1;\n",
       "      } else if (unlikely(__pyx_t_16 &gt;= __pyx_v_S.shape[1])) __pyx_t_15 = 1;\n",
       "      if (unlikely(__pyx_t_15 != -1)) {\n",
       "        <span class='pyx_c_api'>__Pyx_RaiseBufferIndexError</span>(__pyx_t_15);\n",
       "        <span class='error_goto'>__PYX_ERR(0, 21, __pyx_L1_error)</span>\n",
       "      }\n",
       "      *((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_S.data + __pyx_t_17 * __pyx_v_S.strides[0]) ) + __pyx_t_16 * __pyx_v_S.strides[1]) )) = ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_S.data + __pyx_t_7 * __pyx_v_S.strides[0]) ) + __pyx_t_8 * __pyx_v_S.strides[1]) ))) * __pyx_v_d);\n",
       "    }\n",
       "</pre><pre class=\"cython line score-0\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">22</span>:         <span class=\"n\">z</span> <span class=\"o\">+=</span> <span class=\"mf\">1</span></pre>\n",
       "<pre class='cython code score-0 '>    __pyx_v_z = (__pyx_v_z + 1);\n",
       "  }\n",
       "</pre><pre class=\"cython line score-21\" onclick=\"(function(s){s.display=s.display==='block'?'none':'block'})(this.nextElementSibling.style)\">+<span class=\"\">23</span>:     <span class=\"k\">return</span> <span class=\"n\">np</span><span class=\"o\">.</span><span class=\"n\">array</span><span class=\"p\">(</span><span class=\"n\">S</span><span class=\"p\">)</span></pre>\n",
       "<pre class='cython code score-21 '>  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_r);\n",
       "  <span class='pyx_c_api'>__Pyx_GetModuleGlobalName</span>(__pyx_t_4, __pyx_n_s_np);<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);\n",
       "  __pyx_t_3 = <span class='pyx_c_api'>__Pyx_PyObject_GetAttrStr</span>(__pyx_t_4, __pyx_n_s_array);<span class='error_goto'> if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_3);\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;\n",
       "  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_S, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);;<span class='error_goto'> if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_4);\n",
       "  __pyx_t_2 = NULL;\n",
       "  if (CYTHON_UNPACK_METHODS &amp;&amp; unlikely(<span class='py_c_api'>PyMethod_Check</span>(__pyx_t_3))) {\n",
       "    __pyx_t_2 = <span class='py_macro_api'>PyMethod_GET_SELF</span>(__pyx_t_3);\n",
       "    if (likely(__pyx_t_2)) {\n",
       "      PyObject* function = <span class='py_macro_api'>PyMethod_GET_FUNCTION</span>(__pyx_t_3);\n",
       "      <span class='pyx_macro_api'>__Pyx_INCREF</span>(__pyx_t_2);\n",
       "      <span class='pyx_macro_api'>__Pyx_INCREF</span>(function);\n",
       "      <span class='pyx_macro_api'>__Pyx_DECREF_SET</span>(__pyx_t_3, function);\n",
       "    }\n",
       "  }\n",
       "  __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : <span class='pyx_c_api'>__Pyx_PyObject_CallOneArg</span>(__pyx_t_3, __pyx_t_4);\n",
       "  <span class='pyx_macro_api'>__Pyx_XDECREF</span>(__pyx_t_2); __pyx_t_2 = 0;\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_4); __pyx_t_4 = 0;\n",
       "  if (unlikely(!__pyx_t_5)) <span class='error_goto'>__PYX_ERR(0, 23, __pyx_L1_error)</span>\n",
       "  <span class='refnanny'>__Pyx_GOTREF</span>(__pyx_t_5);\n",
       "  <span class='pyx_macro_api'>__Pyx_DECREF</span>(__pyx_t_3); __pyx_t_3 = 0;\n",
       "  __pyx_r = __pyx_t_5;\n",
       "  __pyx_t_5 = 0;\n",
       "  goto __pyx_L0;\n",
       "</pre></div></body></html>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%%cython -a\n",
    "import numpy as np\n",
    "cimport cython\n",
    "from libc.math cimport exp, sqrt\n",
    "cdef float S0 = 36.\n",
    "cdef float T = 1.0\n",
    "cdef float r = 0.06\n",
    "cdef float sigma = 0.2\n",
    "def simulate_tree_cy(int M):\n",
    "    cdef int z, t, i\n",
    "    cdef float dt, u, d\n",
    "    cdef float[:, :] S = np.zeros((M + 1, M + 1),\n",
    "                                  dtype=np.float32)  \n",
    "    dt = T / M\n",
    "    u = exp(sigma * sqrt(dt))\n",
    "    d = 1 / u\n",
    "    S[0, 0] = S0\n",
    "    z = 1\n",
    "    for t in range(1, M + 1):\n",
    "        for i in range(z):\n",
    "            S[i, t] = S[i, t-1] * u\n",
    "            S[i+1, t] = S[i, t-1] * d\n",
    "        z += 1\n",
    "    return np.array(S)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  39.79,  43.97,  48.59,  53.71],\n",
       "       [  0.00,  32.57,  36.00,  39.79,  43.97],\n",
       "       [  0.00,   0.00,  29.47,  32.57,  36.00],\n",
       "       [  0.00,   0.00,   0.00,  26.67,  29.47],\n",
       "       [  0.00,   0.00,   0.00,   0.00,  24.13]], dtype=float32)"
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simulate_tree_cy(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1.11 ms, sys: 1.74 ms, total: 2.84 ms\n",
      "Wall time: 1.45 ms\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([[ 36.00,  36.32,  36.65, ..., 3095.77, 3123.59, 3151.65],\n",
       "       [  0.00,  35.68,  36.00, ..., 3040.89, 3068.21, 3095.77],\n",
       "       [  0.00,   0.00,  35.36, ..., 2986.97, 3013.81, 3040.89],\n",
       "       ...,\n",
       "       [  0.00,   0.00,   0.00, ...,   0.42,   0.42,   0.43],\n",
       "       [  0.00,   0.00,   0.00, ...,   0.00,   0.41,   0.42],\n",
       "       [  0.00,   0.00,   0.00, ...,   0.00,   0.00,   0.41]],\n",
       "      dtype=float32)"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time simulate_tree_cy(500)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "249 µs ± 9.98 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit S = simulate_tree_cy(500)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Monte Carlo Simulation"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [],
   "source": [
    "M = 100  \n",
    "I = 50000  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mcs_simulation_py(p):\n",
    "    M, I = p\n",
    "    dt = T / M\n",
    "    S = np.zeros((M + 1, I))\n",
    "    S[0] = S0\n",
    "    rn = np.random.standard_normal(S.shape)  \n",
    "    for t in range(1, M + 1):  \n",
    "        for i in range(I):  \n",
    "            S[t, i] = S[t-1, i] * math.exp((r - sigma ** 2 / 2) * dt +\n",
    "                                         sigma * math.sqrt(dt) * rn[t, i])  \n",
    "    return S      "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 4.98 s, sys: 28.2 ms, total: 5.01 s\n",
      "Wall time: 5.01 s\n"
     ]
    }
   ],
   "source": [
    "%time S = mcs_simulation_py((M, I))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38.274934679715166"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S[-1].mean()  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38.22611567563295"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S0 * math.exp(r * T)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {},
   "outputs": [],
   "source": [
    "K = 40.  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {},
   "outputs": [],
   "source": [
    "C0 = math.exp(-r * T) * np.maximum(K - S[-1], 0).mean()  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.8308819885853533"
      ]
     },
     "execution_count": 127,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x7f847aa98890>"
      ]
     },
     "execution_count": 128,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"357.238125pt\" version=\"1.1\" viewBox=\"0 0 604.85 357.238125\" width=\"604.85pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 357.238125 \n",
       "L 604.85 357.238125 \n",
       "L 604.85 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 39.65 333.36 \n",
       "L 597.65 333.36 \n",
       "L 597.65 7.2 \n",
       "L 39.65 7.2 \n",
       "z\n",
       "\" style=\"fill:#eaeaf2;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 87.337852 333.36 \n",
       "L 87.337852 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\"/>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 20 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.796875 55.515625 \n",
       "L 7.328125 55.515625 \n",
       "L 7.328125 68.5 \n",
       "Q 12.546875 71.296875 17.84375 72.75 \n",
       "Q 23.140625 74.21875 28.21875 74.21875 \n",
       "Q 39.59375 74.21875 46.1875 68.703125 \n",
       "Q 52.78125 63.1875 52.78125 53.71875 \n",
       "Q 52.78125 43.015625 37.84375 28.125 \n",
       "Q 36.671875 27 36.078125 26.421875 \n",
       "L 17.671875 8.015625 \n",
       "L 48.09375 8.015625 \n",
       "L 48.09375 17 \n",
       "L 53.8125 17 \n",
       "L 53.8125 0 \n",
       "L 6.78125 0 \n",
       "L 6.78125 5.328125 \n",
       "L 28.90625 27.390625 \n",
       "Q 36.234375 34.71875 39.359375 40.84375 \n",
       "Q 42.484375 46.96875 42.484375 53.71875 \n",
       "Q 42.484375 61.078125 38.640625 65.234375 \n",
       "Q 34.8125 69.390625 28.078125 69.390625 \n",
       "Q 21.09375 69.390625 17.28125 65.921875 \n",
       "Q 13.484375 62.453125 12.796875 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-50\"/>\n",
       "       <path d=\"M 31.78125 3.421875 \n",
       "Q 39.265625 3.421875 42.96875 11.625 \n",
       "Q 46.6875 19.828125 46.6875 36.375 \n",
       "Q 46.6875 52.984375 42.96875 61.1875 \n",
       "Q 39.265625 69.390625 31.78125 69.390625 \n",
       "Q 24.3125 69.390625 20.59375 61.1875 \n",
       "Q 16.890625 52.984375 16.890625 36.375 \n",
       "Q 16.890625 19.828125 20.59375 11.625 \n",
       "Q 24.3125 3.421875 31.78125 3.421875 \n",
       "z\n",
       "M 31.78125 -1.421875 \n",
       "Q 19.921875 -1.421875 13.25 8.53125 \n",
       "Q 6.59375 18.5 6.59375 36.375 \n",
       "Q 6.59375 54.296875 13.25 64.25 \n",
       "Q 19.921875 74.21875 31.78125 74.21875 \n",
       "Q 43.703125 74.21875 50.34375 64.25 \n",
       "Q 56.984375 54.296875 56.984375 36.375 \n",
       "Q 56.984375 18.5 50.34375 8.53125 \n",
       "Q 43.703125 -1.421875 31.78125 -1.421875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-48\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(80.975352 347.958438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 152.424593 333.36 \n",
       "L 152.424593 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\"/>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 30 -->\n",
       "      <defs>\n",
       "       <path d=\"M 9.71875 69.828125 \n",
       "Q 15.4375 71.96875 20.671875 73.09375 \n",
       "Q 25.921875 74.21875 30.515625 74.21875 \n",
       "Q 41.21875 74.21875 47.21875 69.59375 \n",
       "Q 53.21875 64.984375 53.21875 56.78125 \n",
       "Q 53.21875 50.203125 49.0625 45.78125 \n",
       "Q 44.921875 41.359375 37.3125 39.796875 \n",
       "Q 46.296875 38.53125 51.25 33.28125 \n",
       "Q 56.203125 28.03125 56.203125 19.671875 \n",
       "Q 56.203125 9.46875 49.34375 4.015625 \n",
       "Q 42.484375 -1.421875 29.59375 -1.421875 \n",
       "Q 23.875 -1.421875 18.421875 -0.1875 \n",
       "Q 12.984375 1.03125 7.625 3.515625 \n",
       "L 7.625 17.671875 \n",
       "L 13.09375 17.671875 \n",
       "Q 13.578125 10.640625 17.828125 7.03125 \n",
       "Q 22.078125 3.421875 29.78125 3.421875 \n",
       "Q 37.25 3.421875 41.578125 7.734375 \n",
       "Q 45.90625 12.0625 45.90625 19.578125 \n",
       "Q 45.90625 28.171875 41.453125 32.59375 \n",
       "Q 37.015625 37.015625 28.421875 37.015625 \n",
       "L 23.78125 37.015625 \n",
       "L 23.78125 42 \n",
       "L 26.21875 42 \n",
       "Q 34.765625 42 39.03125 45.53125 \n",
       "Q 43.3125 49.078125 43.3125 56.203125 \n",
       "Q 43.3125 62.59375 39.796875 65.984375 \n",
       "Q 36.28125 69.390625 29.6875 69.390625 \n",
       "Q 23.09375 69.390625 19.453125 66.265625 \n",
       "Q 15.828125 63.140625 15.1875 56.984375 \n",
       "L 9.71875 56.984375 \n",
       "z\n",
       "\" id=\"DejaVuSerif-51\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(146.062093 347.958438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 217.511334 333.36 \n",
       "L 217.511334 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\"/>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 40 -->\n",
       "      <defs>\n",
       "       <path d=\"M 34.90625 24.703125 \n",
       "L 34.90625 63.484375 \n",
       "L 10.015625 24.703125 \n",
       "z\n",
       "M 56.390625 0 \n",
       "L 23.1875 0 \n",
       "L 23.1875 5.171875 \n",
       "L 34.90625 5.171875 \n",
       "L 34.90625 19.484375 \n",
       "L 3.078125 19.484375 \n",
       "L 3.078125 24.8125 \n",
       "L 35.015625 74.21875 \n",
       "L 44.671875 74.21875 \n",
       "L 44.671875 24.703125 \n",
       "L 58.59375 24.703125 \n",
       "L 58.59375 19.484375 \n",
       "L 44.671875 19.484375 \n",
       "L 44.671875 5.171875 \n",
       "L 56.390625 5.171875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-52\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(211.148834 347.958438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 282.598075 333.36 \n",
       "L 282.598075 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\"/>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 50 -->\n",
       "      <defs>\n",
       "       <path d=\"M 50.296875 72.90625 \n",
       "L 50.296875 64.890625 \n",
       "L 16.890625 64.890625 \n",
       "L 16.890625 44 \n",
       "Q 19.4375 45.75 22.828125 46.625 \n",
       "Q 26.21875 47.515625 30.421875 47.515625 \n",
       "Q 42.234375 47.515625 49.0625 40.96875 \n",
       "Q 55.90625 34.421875 55.90625 23.09375 \n",
       "Q 55.90625 11.53125 49 5.046875 \n",
       "Q 42.09375 -1.421875 29.59375 -1.421875 \n",
       "Q 24.5625 -1.421875 19.28125 -0.1875 \n",
       "Q 14.015625 1.03125 8.5 3.515625 \n",
       "L 8.5 17.671875 \n",
       "L 14.015625 17.671875 \n",
       "Q 14.453125 10.75 18.421875 7.078125 \n",
       "Q 22.40625 3.421875 29.59375 3.421875 \n",
       "Q 37.3125 3.421875 41.453125 8.5 \n",
       "Q 45.609375 13.578125 45.609375 23.09375 \n",
       "Q 45.609375 32.5625 41.484375 37.609375 \n",
       "Q 37.359375 42.671875 29.59375 42.671875 \n",
       "Q 25.203125 42.671875 21.84375 41.109375 \n",
       "Q 18.5 39.546875 15.921875 36.28125 \n",
       "L 11.71875 36.28125 \n",
       "L 11.71875 72.90625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-53\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(276.235575 347.958438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 347.684816 333.36 \n",
       "L 347.684816 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\"/>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 60 -->\n",
       "      <defs>\n",
       "       <path d=\"M 32.71875 3.421875 \n",
       "Q 39.59375 3.421875 43.296875 8.46875 \n",
       "Q 47.015625 13.53125 47.015625 23 \n",
       "Q 47.015625 32.46875 43.296875 37.515625 \n",
       "Q 39.59375 42.578125 32.71875 42.578125 \n",
       "Q 25.734375 42.578125 22.0625 37.6875 \n",
       "Q 18.40625 32.8125 18.40625 23.578125 \n",
       "Q 18.40625 13.875 22.109375 8.640625 \n",
       "Q 25.828125 3.421875 32.71875 3.421875 \n",
       "z\n",
       "M 16.796875 40.140625 \n",
       "Q 20.125 43.796875 24.3125 45.59375 \n",
       "Q 28.515625 47.40625 33.796875 47.40625 \n",
       "Q 44.671875 47.40625 51 40.859375 \n",
       "Q 57.328125 34.328125 57.328125 23 \n",
       "Q 57.328125 11.921875 50.515625 5.25 \n",
       "Q 43.703125 -1.421875 32.328125 -1.421875 \n",
       "Q 19.96875 -1.421875 13.328125 7.78125 \n",
       "Q 6.6875 17 6.6875 34.078125 \n",
       "Q 6.6875 53.21875 14.546875 63.71875 \n",
       "Q 22.40625 74.21875 36.71875 74.21875 \n",
       "Q 40.578125 74.21875 44.828125 73.484375 \n",
       "Q 49.078125 72.75 53.515625 71.296875 \n",
       "L 53.515625 59.28125 \n",
       "L 48 59.28125 \n",
       "Q 47.40625 64.203125 44.234375 66.796875 \n",
       "Q 41.0625 69.390625 35.6875 69.390625 \n",
       "Q 26.21875 69.390625 21.578125 62.203125 \n",
       "Q 16.9375 55.03125 16.796875 40.140625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-54\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(341.322316 347.958438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-54\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 412.771558 333.36 \n",
       "L 412.771558 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\"/>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 70 -->\n",
       "      <defs>\n",
       "       <path d=\"M 56.390625 67.921875 \n",
       "L 27.875 0 \n",
       "L 20.609375 0 \n",
       "L 47.796875 64.890625 \n",
       "L 14.109375 64.890625 \n",
       "L 14.109375 55.90625 \n",
       "L 8.40625 55.90625 \n",
       "L 8.40625 72.90625 \n",
       "L 56.390625 72.90625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-55\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(406.409058 347.958438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 477.858299 333.36 \n",
       "L 477.858299 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\"/>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 80 -->\n",
       "      <defs>\n",
       "       <path d=\"M 46.578125 19.921875 \n",
       "Q 46.578125 27.734375 42.6875 32.046875 \n",
       "Q 38.8125 36.375 31.78125 36.375 \n",
       "Q 24.75 36.375 20.875 32.046875 \n",
       "Q 17 27.734375 17 19.921875 \n",
       "Q 17 12.0625 20.875 7.734375 \n",
       "Q 24.75 3.421875 31.78125 3.421875 \n",
       "Q 38.8125 3.421875 42.6875 7.734375 \n",
       "Q 46.578125 12.0625 46.578125 19.921875 \n",
       "z\n",
       "M 44.578125 55.328125 \n",
       "Q 44.578125 61.96875 41.203125 65.671875 \n",
       "Q 37.84375 69.390625 31.78125 69.390625 \n",
       "Q 25.78125 69.390625 22.390625 65.671875 \n",
       "Q 19 61.96875 19 55.328125 \n",
       "Q 19 48.640625 22.390625 44.921875 \n",
       "Q 25.78125 41.21875 31.78125 41.21875 \n",
       "Q 37.84375 41.21875 41.203125 44.921875 \n",
       "Q 44.578125 48.640625 44.578125 55.328125 \n",
       "z\n",
       "M 39.3125 38.8125 \n",
       "Q 47.609375 37.703125 52.25 32.6875 \n",
       "Q 56.890625 27.6875 56.890625 19.921875 \n",
       "Q 56.890625 9.671875 50.390625 4.125 \n",
       "Q 43.890625 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.203125 4.125 \n",
       "Q 6.6875 9.671875 6.6875 19.921875 \n",
       "Q 6.6875 27.6875 11.328125 32.6875 \n",
       "Q 15.96875 37.703125 24.3125 38.8125 \n",
       "Q 16.9375 40.140625 13 44.40625 \n",
       "Q 9.078125 48.6875 9.078125 55.328125 \n",
       "Q 9.078125 64.109375 15.125 69.15625 \n",
       "Q 21.1875 74.21875 31.78125 74.21875 \n",
       "Q 42.390625 74.21875 48.4375 69.15625 \n",
       "Q 54.5 64.109375 54.5 55.328125 \n",
       "Q 54.5 48.6875 50.5625 44.40625 \n",
       "Q 46.625 40.140625 39.3125 38.8125 \n",
       "z\n",
       "\" id=\"DejaVuSerif-56\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(471.495799 347.958438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-56\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 542.94504 333.36 \n",
       "L 542.94504 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\"/>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 90 -->\n",
       "      <defs>\n",
       "       <path d=\"M 46.78125 32.671875 \n",
       "Q 43.5 29 39.25 27.1875 \n",
       "Q 35.015625 25.390625 29.6875 25.390625 \n",
       "Q 18.84375 25.390625 12.5625 31.9375 \n",
       "Q 6.296875 38.484375 6.296875 49.8125 \n",
       "Q 6.296875 60.890625 13.109375 67.546875 \n",
       "Q 19.921875 74.21875 31.296875 74.21875 \n",
       "Q 43.65625 74.21875 50.265625 65.015625 \n",
       "Q 56.890625 55.8125 56.890625 38.71875 \n",
       "Q 56.890625 19.578125 49.015625 9.078125 \n",
       "Q 41.15625 -1.421875 26.90625 -1.421875 \n",
       "Q 23.046875 -1.421875 18.796875 -0.6875 \n",
       "Q 14.546875 0.046875 10.109375 1.515625 \n",
       "L 10.109375 13.625 \n",
       "L 15.578125 13.625 \n",
       "Q 16.21875 8.6875 19.390625 6.046875 \n",
       "Q 22.5625 3.421875 27.875 3.421875 \n",
       "Q 37.359375 3.421875 41.984375 10.5625 \n",
       "Q 46.625 17.71875 46.78125 32.671875 \n",
       "z\n",
       "M 30.90625 69.390625 \n",
       "Q 23.96875 69.390625 20.28125 64.328125 \n",
       "Q 16.609375 59.28125 16.609375 49.8125 \n",
       "Q 16.609375 40.328125 20.28125 35.25 \n",
       "Q 23.96875 30.171875 30.90625 30.171875 \n",
       "Q 37.84375 30.171875 41.53125 35.078125 \n",
       "Q 45.21875 39.984375 45.21875 49.21875 \n",
       "Q 45.21875 58.9375 41.5 64.15625 \n",
       "Q 37.796875 69.390625 30.90625 69.390625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-57\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(536.58254 347.958438)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-57\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 39.65 333.36 \n",
       "L 597.65 333.36 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\"/>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 0 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(26.2875 337.159219)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 39.65 282.075772 \n",
       "L 597.65 282.075772 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_20\"/>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 1000 -->\n",
       "      <defs>\n",
       "       <path d=\"M 14.203125 0 \n",
       "L 14.203125 5.171875 \n",
       "L 26.90625 5.171875 \n",
       "L 26.90625 65.828125 \n",
       "L 12.203125 56.296875 \n",
       "L 12.203125 62.703125 \n",
       "L 29.984375 74.21875 \n",
       "L 36.71875 74.21875 \n",
       "L 36.71875 5.171875 \n",
       "L 49.421875 5.171875 \n",
       "L 49.421875 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-49\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 285.87499)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 39.65 230.791543 \n",
       "L 597.65 230.791543 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_22\"/>\n",
       "     <g id=\"text_11\">\n",
       "      <!-- 2000 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 234.590762)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_23\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 39.65 179.507315 \n",
       "L 597.65 179.507315 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_24\"/>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 3000 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 183.306534)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-51\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_25\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 39.65 128.223086 \n",
       "L 597.65 128.223086 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_26\"/>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 4000 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 132.022305)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-52\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_27\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 39.65 76.938858 \n",
       "L 597.65 76.938858 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_28\"/>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 5000 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 80.738077)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-53\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_29\">\n",
       "      <path clip-path=\"url(#p36ac28a16c)\" d=\"M 39.65 25.65463 \n",
       "L 597.65 25.65463 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_30\"/>\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 6000 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 29.453848)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-54\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 65.013636 333.36 \n",
       "L 79.507143 333.36 \n",
       "L 79.507143 332.898442 \n",
       "L 65.013636 332.898442 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 79.507143 333.36 \n",
       "L 94.000649 333.36 \n",
       "L 94.000649 328.744419 \n",
       "L 79.507143 328.744419 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 94.000649 333.36 \n",
       "L 108.494156 333.36 \n",
       "L 108.494156 317.872163 \n",
       "L 94.000649 317.872163 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 108.494156 333.36 \n",
       "L 122.987662 333.36 \n",
       "L 122.987662 284.84512 \n",
       "L 108.494156 284.84512 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_7\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 122.987662 333.36 \n",
       "L 137.481169 333.36 \n",
       "L 137.481169 233.253186 \n",
       "L 122.987662 233.253186 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_8\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 137.481169 333.36 \n",
       "L 151.974675 333.36 \n",
       "L 151.974675 167.147816 \n",
       "L 137.481169 167.147816 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_9\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 151.974675 333.36 \n",
       "L 166.468182 333.36 \n",
       "L 166.468182 102.939962 \n",
       "L 151.974675 102.939962 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_10\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 166.468182 333.36 \n",
       "L 180.961688 333.36 \n",
       "L 180.961688 45.860616 \n",
       "L 166.468182 45.860616 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_11\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 180.961688 333.36 \n",
       "L 195.455195 333.36 \n",
       "L 195.455195 22.731429 \n",
       "L 180.961688 22.731429 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_12\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 195.455195 333.36 \n",
       "L 209.948701 333.36 \n",
       "L 209.948701 38.885961 \n",
       "L 195.455195 38.885961 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_13\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 209.948701 333.36 \n",
       "L 224.442208 333.36 \n",
       "L 224.442208 64.322938 \n",
       "L 209.948701 64.322938 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_14\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 224.442208 333.36 \n",
       "L 238.935714 333.36 \n",
       "L 238.935714 104.73491 \n",
       "L 224.442208 104.73491 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_15\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 238.935714 333.36 \n",
       "L 253.429221 333.36 \n",
       "L 253.429221 156.685833 \n",
       "L 238.935714 156.685833 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_16\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 253.429221 333.36 \n",
       "L 267.922727 333.36 \n",
       "L 267.922727 197.867069 \n",
       "L 253.429221 197.867069 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_17\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 267.922727 333.36 \n",
       "L 282.416234 333.36 \n",
       "L 282.416234 235.150703 \n",
       "L 267.922727 235.150703 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_18\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 282.416234 333.36 \n",
       "L 296.90974 333.36 \n",
       "L 296.90974 263.459597 \n",
       "L 282.416234 263.459597 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_19\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 296.90974 333.36 \n",
       "L 311.403247 333.36 \n",
       "L 311.403247 287.255479 \n",
       "L 296.90974 287.255479 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_20\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 311.403247 333.36 \n",
       "L 325.896753 333.36 \n",
       "L 325.896753 303.871569 \n",
       "L 311.403247 303.871569 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_21\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 325.896753 333.36 \n",
       "L 340.39026 333.36 \n",
       "L 340.39026 311.153929 \n",
       "L 325.896753 311.153929 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_22\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 340.39026 333.36 \n",
       "L 354.883766 333.36 \n",
       "L 354.883766 322.333891 \n",
       "L 340.39026 322.333891 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_23\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 354.883766 333.36 \n",
       "L 369.377273 333.36 \n",
       "L 369.377273 325.872503 \n",
       "L 354.883766 325.872503 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_24\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 369.377273 333.36 \n",
       "L 383.870779 333.36 \n",
       "L 383.870779 328.436714 \n",
       "L 369.377273 328.436714 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_25\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 383.870779 333.36 \n",
       "L 398.364286 333.36 \n",
       "L 398.364286 330.641936 \n",
       "L 383.870779 330.641936 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_26\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 398.364286 333.36 \n",
       "L 412.857792 333.36 \n",
       "L 412.857792 331.565052 \n",
       "L 398.364286 331.565052 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_27\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 412.857792 333.36 \n",
       "L 427.351299 333.36 \n",
       "L 427.351299 332.3856 \n",
       "L 412.857792 332.3856 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_28\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 427.351299 333.36 \n",
       "L 441.844805 333.36 \n",
       "L 441.844805 332.744589 \n",
       "L 427.351299 332.744589 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_29\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 441.844805 333.36 \n",
       "L 456.338312 333.36 \n",
       "L 456.338312 333.154863 \n",
       "L 441.844805 333.154863 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_30\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 456.338312 333.36 \n",
       "L 470.831818 333.36 \n",
       "L 470.831818 333.257432 \n",
       "L 456.338312 333.257432 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_31\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 470.831818 333.36 \n",
       "L 485.325325 333.36 \n",
       "L 485.325325 333.308716 \n",
       "L 470.831818 333.308716 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_32\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 485.325325 333.36 \n",
       "L 499.818831 333.36 \n",
       "L 499.818831 333.308716 \n",
       "L 485.325325 333.308716 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_33\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 499.818831 333.36 \n",
       "L 514.312338 333.36 \n",
       "L 514.312338 333.308716 \n",
       "L 499.818831 333.308716 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_34\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 514.312338 333.36 \n",
       "L 528.805844 333.36 \n",
       "L 528.805844 333.36 \n",
       "L 514.312338 333.36 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_35\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 528.805844 333.36 \n",
       "L 543.299351 333.36 \n",
       "L 543.299351 333.36 \n",
       "L 528.805844 333.36 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_36\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 543.299351 333.36 \n",
       "L 557.792857 333.36 \n",
       "L 557.792857 333.36 \n",
       "L 543.299351 333.36 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_37\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 557.792857 333.36 \n",
       "L 572.286364 333.36 \n",
       "L 572.286364 333.308716 \n",
       "L 557.792857 333.308716 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_31\">\n",
       "    <path clip-path=\"url(#p36ac28a16c)\" d=\"M 206.283446 333.36 \n",
       "L 206.283446 7.2 \n",
       "\" style=\"fill:none;stroke:#ff0000;stroke-linecap:round;stroke-width:1.75;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_38\">\n",
       "    <path d=\"M 39.65 333.36 \n",
       "L 39.65 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_39\">\n",
       "    <path d=\"M 597.65 333.36 \n",
       "L 597.65 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_40\">\n",
       "    <path d=\"M 39.65 333.36 \n",
       "L 597.65 333.36 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_41\">\n",
       "    <path d=\"M 39.65 7.2 \n",
       "L 597.65 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"line2d_32\">\n",
       "     <path d=\"M 502.496875 20.298438 \n",
       "L 522.496875 20.298438 \n",
       "\" style=\"fill:none;stroke:#ff0000;stroke-linecap:round;stroke-width:1.75;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_33\"/>\n",
       "    <g id=\"text_16\">\n",
       "     <!-- mean value -->\n",
       "     <defs>\n",
       "      <path d=\"M 51.8125 41.796875 \n",
       "Q 54.390625 47.515625 58.421875 50.421875 \n",
       "Q 62.453125 53.328125 67.828125 53.328125 \n",
       "Q 75.984375 53.328125 79.984375 48.265625 \n",
       "Q 83.984375 43.21875 83.984375 33.015625 \n",
       "L 83.984375 5.171875 \n",
       "L 92.09375 5.171875 \n",
       "L 92.09375 0 \n",
       "L 67.1875 0 \n",
       "L 67.1875 5.171875 \n",
       "L 75 5.171875 \n",
       "L 75 31.984375 \n",
       "Q 75 39.9375 72.65625 43.3125 \n",
       "Q 70.3125 46.6875 64.890625 46.6875 \n",
       "Q 58.890625 46.6875 55.734375 42.140625 \n",
       "Q 52.59375 37.59375 52.59375 28.90625 \n",
       "L 52.59375 5.171875 \n",
       "L 60.40625 5.171875 \n",
       "L 60.40625 0 \n",
       "L 35.796875 0 \n",
       "L 35.796875 5.171875 \n",
       "L 43.609375 5.171875 \n",
       "L 43.609375 32.328125 \n",
       "Q 43.609375 40.09375 41.265625 43.390625 \n",
       "Q 38.921875 46.6875 33.5 46.6875 \n",
       "Q 27.484375 46.6875 24.328125 42.140625 \n",
       "Q 21.1875 37.59375 21.1875 28.90625 \n",
       "L 21.1875 5.171875 \n",
       "L 29 5.171875 \n",
       "L 29 0 \n",
       "L 4.109375 0 \n",
       "L 4.109375 5.171875 \n",
       "L 12.203125 5.171875 \n",
       "L 12.203125 46.78125 \n",
       "L 3.609375 46.78125 \n",
       "L 3.609375 51.90625 \n",
       "L 21.1875 51.90625 \n",
       "L 21.1875 42.671875 \n",
       "Q 23.6875 47.859375 27.53125 50.59375 \n",
       "Q 31.390625 53.328125 36.28125 53.328125 \n",
       "Q 42.328125 53.328125 46.375 50.3125 \n",
       "Q 50.4375 47.3125 51.8125 41.796875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-109\"/>\n",
       "      <path d=\"M 54.203125 25 \n",
       "L 15.484375 25 \n",
       "L 15.484375 24.609375 \n",
       "Q 15.484375 14.109375 19.4375 8.765625 \n",
       "Q 23.390625 3.421875 31.109375 3.421875 \n",
       "Q 37.015625 3.421875 40.796875 6.515625 \n",
       "Q 44.578125 9.625 46.09375 15.71875 \n",
       "L 53.328125 15.71875 \n",
       "Q 51.171875 7.171875 45.375 2.875 \n",
       "Q 39.59375 -1.421875 30.171875 -1.421875 \n",
       "Q 18.796875 -1.421875 11.890625 6.078125 \n",
       "Q 4.984375 13.578125 4.984375 25.984375 \n",
       "Q 4.984375 38.28125 11.765625 45.796875 \n",
       "Q 18.5625 53.328125 29.59375 53.328125 \n",
       "Q 41.359375 53.328125 47.65625 46.0625 \n",
       "Q 53.953125 38.8125 54.203125 25 \n",
       "z\n",
       "M 43.609375 30.171875 \n",
       "Q 43.3125 39.265625 39.765625 43.875 \n",
       "Q 36.234375 48.484375 29.59375 48.484375 \n",
       "Q 23.390625 48.484375 19.828125 43.84375 \n",
       "Q 16.265625 39.203125 15.484375 30.171875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-101\"/>\n",
       "      <path d=\"M 39.796875 16.3125 \n",
       "L 39.796875 27.296875 \n",
       "L 28.21875 27.296875 \n",
       "Q 21.53125 27.296875 18.25 24.40625 \n",
       "Q 14.984375 21.53125 14.984375 15.578125 \n",
       "Q 14.984375 10.15625 18.296875 6.984375 \n",
       "Q 21.625 3.8125 27.296875 3.8125 \n",
       "Q 32.90625 3.8125 36.34375 7.28125 \n",
       "Q 39.796875 10.75 39.796875 16.3125 \n",
       "z\n",
       "M 48.78125 32.421875 \n",
       "L 48.78125 5.171875 \n",
       "L 56.78125 5.171875 \n",
       "L 56.78125 0 \n",
       "L 39.796875 0 \n",
       "L 39.796875 5.609375 \n",
       "Q 36.8125 2 32.90625 0.28125 \n",
       "Q 29 -1.421875 23.78125 -1.421875 \n",
       "Q 15.140625 -1.421875 10.0625 3.171875 \n",
       "Q 4.984375 7.765625 4.984375 15.578125 \n",
       "Q 4.984375 23.640625 10.796875 28.078125 \n",
       "Q 16.609375 32.515625 27.203125 32.515625 \n",
       "L 39.796875 32.515625 \n",
       "L 39.796875 36.078125 \n",
       "Q 39.796875 42 36.203125 45.234375 \n",
       "Q 32.625 48.484375 26.125 48.484375 \n",
       "Q 20.75 48.484375 17.578125 46.046875 \n",
       "Q 14.40625 43.609375 13.625 38.8125 \n",
       "L 8.984375 38.8125 \n",
       "L 8.984375 49.3125 \n",
       "Q 13.671875 51.3125 18.09375 52.3125 \n",
       "Q 22.515625 53.328125 26.703125 53.328125 \n",
       "Q 37.5 53.328125 43.140625 47.96875 \n",
       "Q 48.78125 42.625 48.78125 32.421875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-97\"/>\n",
       "      <path d=\"M 4.109375 0 \n",
       "L 4.109375 5.171875 \n",
       "L 12.203125 5.171875 \n",
       "L 12.203125 46.6875 \n",
       "L 3.609375 46.6875 \n",
       "L 3.609375 51.90625 \n",
       "L 21.1875 51.90625 \n",
       "L 21.1875 42.671875 \n",
       "Q 23.6875 47.953125 27.65625 50.640625 \n",
       "Q 31.640625 53.328125 36.921875 53.328125 \n",
       "Q 45.515625 53.328125 49.5625 48.390625 \n",
       "Q 53.609375 43.453125 53.609375 33.015625 \n",
       "L 53.609375 5.171875 \n",
       "L 61.625 5.171875 \n",
       "L 61.625 0 \n",
       "L 36.8125 0 \n",
       "L 36.8125 5.171875 \n",
       "L 44.578125 5.171875 \n",
       "L 44.578125 30.171875 \n",
       "Q 44.578125 39.703125 42.234375 43.234375 \n",
       "Q 39.890625 46.78125 33.984375 46.78125 \n",
       "Q 27.734375 46.78125 24.453125 42.203125 \n",
       "Q 21.1875 37.640625 21.1875 28.90625 \n",
       "L 21.1875 5.171875 \n",
       "L 29 5.171875 \n",
       "L 29 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-110\"/>\n",
       "      <path id=\"DejaVuSerif-32\"/>\n",
       "      <path d=\"M 24.703125 0 \n",
       "L 5.609375 46.6875 \n",
       "L -0.296875 46.6875 \n",
       "L -0.296875 51.90625 \n",
       "L 23.578125 51.90625 \n",
       "L 23.578125 46.6875 \n",
       "L 15.28125 46.6875 \n",
       "L 29.890625 10.984375 \n",
       "L 44.484375 46.6875 \n",
       "L 36.71875 46.6875 \n",
       "L 36.71875 51.90625 \n",
       "L 56.203125 51.90625 \n",
       "L 56.203125 46.6875 \n",
       "L 50.390625 46.6875 \n",
       "L 31.296875 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-118\"/>\n",
       "      <path d=\"M 20.515625 5.171875 \n",
       "L 29 5.171875 \n",
       "L 29 0 \n",
       "L 2.875 0 \n",
       "L 2.875 5.171875 \n",
       "L 11.53125 5.171875 \n",
       "L 11.53125 70.796875 \n",
       "L 2.875 70.796875 \n",
       "L 2.875 75.984375 \n",
       "L 20.515625 75.984375 \n",
       "z\n",
       "\" id=\"DejaVuSerif-108\"/>\n",
       "      <path d=\"M 35.40625 51.90625 \n",
       "L 52.203125 51.90625 \n",
       "L 52.203125 5.171875 \n",
       "L 60.6875 5.171875 \n",
       "L 60.6875 0 \n",
       "L 43.21875 0 \n",
       "L 43.21875 9.1875 \n",
       "Q 40.71875 4 36.765625 1.28125 \n",
       "Q 32.8125 -1.421875 27.59375 -1.421875 \n",
       "Q 18.953125 -1.421875 14.875 3.484375 \n",
       "Q 10.796875 8.40625 10.796875 18.890625 \n",
       "L 10.796875 46.6875 \n",
       "L 2.6875 46.6875 \n",
       "L 2.6875 51.90625 \n",
       "L 19.828125 51.90625 \n",
       "L 19.828125 21.6875 \n",
       "Q 19.828125 12.203125 22.140625 8.6875 \n",
       "Q 24.46875 5.171875 30.421875 5.171875 \n",
       "Q 36.671875 5.171875 39.9375 9.765625 \n",
       "Q 43.21875 14.359375 43.21875 23.09375 \n",
       "L 43.21875 46.6875 \n",
       "L 35.40625 46.6875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-117\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(530.496875 23.798438)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSerif-109\"/>\n",
       "      <use x=\"94.824219\" xlink:href=\"#DejaVuSerif-101\"/>\n",
       "      <use x=\"154.003906\" xlink:href=\"#DejaVuSerif-97\"/>\n",
       "      <use x=\"213.623047\" xlink:href=\"#DejaVuSerif-110\"/>\n",
       "      <use x=\"278.027344\" xlink:href=\"#DejaVuSerif-32\"/>\n",
       "      <use x=\"309.814453\" xlink:href=\"#DejaVuSerif-118\"/>\n",
       "      <use x=\"366.308594\" xlink:href=\"#DejaVuSerif-97\"/>\n",
       "      <use x=\"425.927734\" xlink:href=\"#DejaVuSerif-108\"/>\n",
       "      <use x=\"457.910156\" xlink:href=\"#DejaVuSerif-117\"/>\n",
       "      <use x=\"522.314453\" xlink:href=\"#DejaVuSerif-101\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"patch_42\">\n",
       "     <path d=\"M 502.496875 38.476563 \n",
       "L 522.496875 38.476563 \n",
       "L 522.496875 31.476563 \n",
       "L 502.496875 31.476563 \n",
       "z\n",
       "\" style=\"fill:#4c72b0;\"/>\n",
       "    </g>\n",
       "    <g id=\"text_17\">\n",
       "     <!-- frequency -->\n",
       "     <defs>\n",
       "      <path d=\"M 43.015625 63.71875 \n",
       "L 38.28125 63.71875 \n",
       "Q 38.234375 67.390625 36.203125 69.28125 \n",
       "Q 34.1875 71.1875 30.328125 71.1875 \n",
       "Q 25.296875 71.1875 23.234375 68.421875 \n",
       "Q 21.1875 65.671875 21.1875 58.59375 \n",
       "L 21.1875 51.90625 \n",
       "L 35.6875 51.90625 \n",
       "L 35.6875 46.6875 \n",
       "L 21.1875 46.6875 \n",
       "L 21.1875 5.171875 \n",
       "L 32.71875 5.171875 \n",
       "L 32.71875 0 \n",
       "L 3.609375 0 \n",
       "L 3.609375 5.171875 \n",
       "L 12.203125 5.171875 \n",
       "L 12.203125 46.6875 \n",
       "L 3.609375 46.6875 \n",
       "L 3.609375 51.90625 \n",
       "L 12.203125 51.90625 \n",
       "L 12.203125 58.40625 \n",
       "Q 12.203125 67.09375 16.71875 71.53125 \n",
       "Q 21.234375 75.984375 29.984375 75.984375 \n",
       "Q 33.25 75.984375 36.515625 75.390625 \n",
       "Q 39.796875 74.8125 43.015625 73.578125 \n",
       "z\n",
       "\" id=\"DejaVuSerif-102\"/>\n",
       "      <path d=\"M 47.796875 52 \n",
       "L 47.796875 39.015625 \n",
       "L 42.625 39.015625 \n",
       "Q 42.390625 42.875 40.484375 44.78125 \n",
       "Q 38.578125 46.6875 34.90625 46.6875 \n",
       "Q 28.265625 46.6875 24.71875 42.09375 \n",
       "Q 21.1875 37.5 21.1875 28.90625 \n",
       "L 21.1875 5.171875 \n",
       "L 31.59375 5.171875 \n",
       "L 31.59375 0 \n",
       "L 4.109375 0 \n",
       "L 4.109375 5.171875 \n",
       "L 12.203125 5.171875 \n",
       "L 12.203125 46.78125 \n",
       "L 3.609375 46.78125 \n",
       "L 3.609375 51.90625 \n",
       "L 21.1875 51.90625 \n",
       "L 21.1875 42.671875 \n",
       "Q 23.828125 48.09375 27.96875 50.703125 \n",
       "Q 32.125 53.328125 38.09375 53.328125 \n",
       "Q 40.28125 53.328125 42.703125 52.984375 \n",
       "Q 45.125 52.640625 47.796875 52 \n",
       "z\n",
       "\" id=\"DejaVuSerif-114\"/>\n",
       "      <path d=\"M 52.484375 46.6875 \n",
       "L 52.484375 -15.578125 \n",
       "L 61.078125 -15.578125 \n",
       "L 61.078125 -20.796875 \n",
       "L 35.015625 -20.796875 \n",
       "L 35.015625 -15.578125 \n",
       "L 43.5 -15.578125 \n",
       "L 43.5 8.109375 \n",
       "Q 40.875 3.21875 36.796875 0.890625 \n",
       "Q 32.71875 -1.421875 26.703125 -1.421875 \n",
       "Q 17.140625 -1.421875 11.0625 6.171875 \n",
       "Q 4.984375 13.765625 4.984375 25.984375 \n",
       "Q 4.984375 38.1875 11.03125 45.75 \n",
       "Q 17.09375 53.328125 26.703125 53.328125 \n",
       "Q 32.71875 53.328125 36.796875 51 \n",
       "Q 40.875 48.6875 43.5 43.796875 \n",
       "L 43.5 51.90625 \n",
       "L 61.078125 51.90625 \n",
       "L 61.078125 46.6875 \n",
       "z\n",
       "M 43.5 28.515625 \n",
       "Q 43.5 37.84375 39.90625 42.765625 \n",
       "Q 36.328125 47.703125 29.5 47.703125 \n",
       "Q 22.5625 47.703125 19.015625 42.234375 \n",
       "Q 15.484375 36.765625 15.484375 25.984375 \n",
       "Q 15.484375 15.234375 19.015625 9.71875 \n",
       "Q 22.5625 4.203125 29.5 4.203125 \n",
       "Q 36.328125 4.203125 39.90625 9.109375 \n",
       "Q 43.5 14.015625 43.5 23.390625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-113\"/>\n",
       "      <path d=\"M 51.421875 15.578125 \n",
       "Q 49.515625 7.28125 44.09375 2.921875 \n",
       "Q 38.671875 -1.421875 30.078125 -1.421875 \n",
       "Q 18.75 -1.421875 11.859375 6.078125 \n",
       "Q 4.984375 13.578125 4.984375 25.984375 \n",
       "Q 4.984375 38.421875 11.859375 45.875 \n",
       "Q 18.75 53.328125 30.078125 53.328125 \n",
       "Q 35.015625 53.328125 39.890625 52.171875 \n",
       "Q 44.78125 51.03125 49.703125 48.6875 \n",
       "L 49.703125 35.40625 \n",
       "L 44.484375 35.40625 \n",
       "Q 43.453125 42.234375 40.015625 45.359375 \n",
       "Q 36.578125 48.484375 30.171875 48.484375 \n",
       "Q 22.90625 48.484375 19.1875 42.84375 \n",
       "Q 15.484375 37.203125 15.484375 25.984375 \n",
       "Q 15.484375 14.75 19.171875 9.078125 \n",
       "Q 22.859375 3.421875 30.171875 3.421875 \n",
       "Q 35.984375 3.421875 39.453125 6.4375 \n",
       "Q 42.921875 9.46875 44.1875 15.578125 \n",
       "z\n",
       "\" id=\"DejaVuSerif-99\"/>\n",
       "      <path d=\"M 21.578125 -9.515625 \n",
       "L 25 -0.875 \n",
       "L 5.609375 46.6875 \n",
       "L -0.296875 46.6875 \n",
       "L -0.296875 51.90625 \n",
       "L 23.578125 51.90625 \n",
       "L 23.578125 46.6875 \n",
       "L 15.28125 46.6875 \n",
       "L 29.890625 10.984375 \n",
       "L 44.484375 46.6875 \n",
       "L 36.71875 46.6875 \n",
       "L 36.71875 51.90625 \n",
       "L 56.203125 51.90625 \n",
       "L 56.203125 46.6875 \n",
       "L 50.390625 46.6875 \n",
       "L 26.609375 -11.71875 \n",
       "Q 24.171875 -17.78125 21.1875 -20 \n",
       "Q 18.21875 -22.21875 12.796875 -22.21875 \n",
       "Q 10.5 -22.21875 8.078125 -21.828125 \n",
       "Q 5.671875 -21.4375 3.21875 -20.703125 \n",
       "L 3.21875 -10.796875 \n",
       "L 7.8125 -10.796875 \n",
       "Q 8.109375 -14.109375 9.5 -15.546875 \n",
       "Q 10.890625 -17 13.8125 -17 \n",
       "Q 16.5 -17 18.140625 -15.5 \n",
       "Q 19.78125 -14.015625 21.578125 -9.515625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-121\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(530.496875 38.476563)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSerif-102\"/>\n",
       "      <use x=\"37.011719\" xlink:href=\"#DejaVuSerif-114\"/>\n",
       "      <use x=\"84.814453\" xlink:href=\"#DejaVuSerif-101\"/>\n",
       "      <use x=\"143.994141\" xlink:href=\"#DejaVuSerif-113\"/>\n",
       "      <use x=\"208.007812\" xlink:href=\"#DejaVuSerif-117\"/>\n",
       "      <use x=\"272.412109\" xlink:href=\"#DejaVuSerif-101\"/>\n",
       "      <use x=\"331.591797\" xlink:href=\"#DejaVuSerif-110\"/>\n",
       "      <use x=\"395.996094\" xlink:href=\"#DejaVuSerif-99\"/>\n",
       "      <use x=\"452.001953\" xlink:href=\"#DejaVuSerif-121\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"p36ac28a16c\">\n",
       "   <rect height=\"326.16\" width=\"558\" x=\"39.65\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 720x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(10, 6))\n",
    "plt.hist(S[-1], bins=35, label='frequency')\n",
    "plt.axvline(S[-1].mean(), color='r', label='mean value')\n",
    "plt.legend(loc=0)\n",
    "# plt.savefig('../../images/ch10/perf_02.png');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### NumPy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mcs_simulation_np(p):\n",
    "    M, I = p\n",
    "    dt = T / M\n",
    "    S = np.zeros((M + 1, I))\n",
    "    S[0] = S0\n",
    "    rn = np.random.standard_normal(S.shape)\n",
    "    for t in range(1, M + 1):  \n",
    "        S[t] = S[t-1] * np.exp((r - sigma ** 2 / 2) * dt +\n",
    "                               sigma * math.sqrt(dt) * rn[t]) \n",
    "    return S      "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 175 ms, sys: 20.2 ms, total: 195 ms\n",
      "Wall time: 193 ms\n"
     ]
    }
   ],
   "source": [
    "%time S = mcs_simulation_np((M, I))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38.26515894490085"
      ]
     },
     "execution_count": 131,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S[-1].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "160 ms ± 5.1 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit S = mcs_simulation_np((M, I))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Numba "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "metadata": {},
   "outputs": [],
   "source": [
    "mcs_simulation_nb = numba.jit(mcs_simulation_py)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 348 ms, sys: 11.3 ms, total: 359 ms\n",
      "Wall time: 358 ms\n"
     ]
    }
   ],
   "source": [
    "%time S = mcs_simulation_nb((M, I))  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 132 ms, sys: 4.91 ms, total: 137 ms\n",
      "Wall time: 136 ms\n"
     ]
    }
   ],
   "source": [
    "%time S = mcs_simulation_nb((M, I))  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38.241898982841114"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S[-1].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [],
   "source": [
    "C0 = math.exp(-r * T) * np.maximum(K - S[-1], 0).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.8468323729079708"
      ]
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "134 ms ± 1.04 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit S = mcs_simulation_nb((M, I))  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cython &mdash; Sequential"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%cython\n",
    "import numpy as np\n",
    "cimport numpy as np\n",
    "cimport cython\n",
    "from libc.math cimport exp, sqrt\n",
    "cdef float S0 = 36.\n",
    "cdef float T = 1.0\n",
    "cdef float r = 0.06\n",
    "cdef float sigma = 0.2\n",
    "@cython.boundscheck(False)\n",
    "@cython.wraparound(False)\n",
    "def mcs_simulation_cy(p):\n",
    "    cdef int M, I\n",
    "    M, I = p\n",
    "    cdef int t, i\n",
    "    cdef float dt = T / M\n",
    "    cdef double[:, :] S = np.zeros((M + 1, I))\n",
    "    cdef double[:, :] rn = np.random.standard_normal((M + 1, I))\n",
    "    S[0] = S0\n",
    "    for t in range(1, M + 1):\n",
    "        for i in range(I):\n",
    "            S[t, i] = S[t-1, i] * exp((r - sigma ** 2 / 2) * dt +\n",
    "                                         sigma * sqrt(dt) * rn[t, i])\n",
    "    return np.array(S) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 170 ms, sys: 30.2 ms, total: 200 ms\n",
      "Wall time: 199 ms\n"
     ]
    }
   ],
   "source": [
    "%time S = mcs_simulation_cy((M, I))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38.17874402796526"
      ]
     },
     "execution_count": 142,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S[-1].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 143,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "153 ms ± 2.72 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit S = mcs_simulation_cy((M, I))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Multiprocessing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "metadata": {},
   "outputs": [],
   "source": [
    "import multiprocessing as mp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "metadata": {},
   "outputs": [],
   "source": [
    "pool = mp.Pool(processes=4)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "metadata": {},
   "outputs": [],
   "source": [
    "p = 20  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "156 ms ± 13 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit S = np.hstack(pool.map(mcs_simulation_np, p * [(M, int(I / p))]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "167 ms ± 10.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ]
    }
   ],
   "source": [
    "%timeit S = np.hstack(pool.map(mcs_simulation_nb, p * [(M, int(I / p))]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "162 ms ± 13.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ]
    }
   ],
   "source": [
    "%timeit S = np.hstack(pool.map(mcs_simulation_cy, p * [(M, int(I / p))]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Recursive pandas Algorithm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Data and Formula"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numba\n",
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "metadata": {},
   "outputs": [],
   "source": [
    "sym = 'SPY'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.DataFrame(pd.read_csv('http://hilpisch.com/tr_eikon_eod_data.csv',\n",
    "                               index_col=0, parse_dates=True)[sym]).dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "metadata": {},
   "outputs": [],
   "source": [
    "alpha = 0.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [],
   "source": [
    "data['EWMA'] = data[sym]  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 592 ms, sys: 7.65 ms, total: 599 ms\n",
      "Wall time: 594 ms\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "for t in zip(data.index, data.index[1:]):\n",
    "    data.loc[t[1], 'EWMA'] = (alpha * data.loc[t[1], sym] +\n",
    "                              (1 - alpha) * data.loc[t[0], 'EWMA'])  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SPY</th>\n",
       "      <th>EWMA</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2010-01-04</th>\n",
       "      <td>113.33</td>\n",
       "      <td>113.330000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-05</th>\n",
       "      <td>113.63</td>\n",
       "      <td>113.405000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-06</th>\n",
       "      <td>113.71</td>\n",
       "      <td>113.481250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-07</th>\n",
       "      <td>114.19</td>\n",
       "      <td>113.658438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-08</th>\n",
       "      <td>114.57</td>\n",
       "      <td>113.886328</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               SPY        EWMA\n",
       "Date                          \n",
       "2010-01-04  113.33  113.330000\n",
       "2010-01-05  113.63  113.405000\n",
       "2010-01-06  113.71  113.481250\n",
       "2010-01-07  114.19  113.658438\n",
       "2010-01-08  114.57  113.886328"
      ]
     },
     "execution_count": 156,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"358.964783pt\" version=\"1.1\" viewBox=\"0 0 598.4875 358.964783\" width=\"598.4875pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <defs>\n",
       "  <style type=\"text/css\">\n",
       "*{stroke-linecap:butt;stroke-linejoin:round;}\n",
       "  </style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 358.964783 \n",
       "L 598.4875 358.964783 \n",
       "L 598.4875 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 33.2875 300.96 \n",
       "L 591.2875 300.96 \n",
       "L 591.2875 7.2 \n",
       "L 33.2875 7.2 \n",
       "z\n",
       "\" style=\"fill:#eaeaf2;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 56.779281 300.96 \n",
       "L 56.779281 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\"/>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- 2017-01 -->\n",
       "      <defs>\n",
       "       <path d=\"M 12.796875 55.515625 \n",
       "L 7.328125 55.515625 \n",
       "L 7.328125 68.5 \n",
       "Q 12.546875 71.296875 17.84375 72.75 \n",
       "Q 23.140625 74.21875 28.21875 74.21875 \n",
       "Q 39.59375 74.21875 46.1875 68.703125 \n",
       "Q 52.78125 63.1875 52.78125 53.71875 \n",
       "Q 52.78125 43.015625 37.84375 28.125 \n",
       "Q 36.671875 27 36.078125 26.421875 \n",
       "L 17.671875 8.015625 \n",
       "L 48.09375 8.015625 \n",
       "L 48.09375 17 \n",
       "L 53.8125 17 \n",
       "L 53.8125 0 \n",
       "L 6.78125 0 \n",
       "L 6.78125 5.328125 \n",
       "L 28.90625 27.390625 \n",
       "Q 36.234375 34.71875 39.359375 40.84375 \n",
       "Q 42.484375 46.96875 42.484375 53.71875 \n",
       "Q 42.484375 61.078125 38.640625 65.234375 \n",
       "Q 34.8125 69.390625 28.078125 69.390625 \n",
       "Q 21.09375 69.390625 17.28125 65.921875 \n",
       "Q 13.484375 62.453125 12.796875 55.515625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-50\"/>\n",
       "       <path d=\"M 31.78125 3.421875 \n",
       "Q 39.265625 3.421875 42.96875 11.625 \n",
       "Q 46.6875 19.828125 46.6875 36.375 \n",
       "Q 46.6875 52.984375 42.96875 61.1875 \n",
       "Q 39.265625 69.390625 31.78125 69.390625 \n",
       "Q 24.3125 69.390625 20.59375 61.1875 \n",
       "Q 16.890625 52.984375 16.890625 36.375 \n",
       "Q 16.890625 19.828125 20.59375 11.625 \n",
       "Q 24.3125 3.421875 31.78125 3.421875 \n",
       "z\n",
       "M 31.78125 -1.421875 \n",
       "Q 19.921875 -1.421875 13.25 8.53125 \n",
       "Q 6.59375 18.5 6.59375 36.375 \n",
       "Q 6.59375 54.296875 13.25 64.25 \n",
       "Q 19.921875 74.21875 31.78125 74.21875 \n",
       "Q 43.703125 74.21875 50.34375 64.25 \n",
       "Q 56.984375 54.296875 56.984375 36.375 \n",
       "Q 56.984375 18.5 50.34375 8.53125 \n",
       "Q 43.703125 -1.421875 31.78125 -1.421875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-48\"/>\n",
       "       <path d=\"M 14.203125 0 \n",
       "L 14.203125 5.171875 \n",
       "L 26.90625 5.171875 \n",
       "L 26.90625 65.828125 \n",
       "L 12.203125 56.296875 \n",
       "L 12.203125 62.703125 \n",
       "L 29.984375 74.21875 \n",
       "L 36.71875 74.21875 \n",
       "L 36.71875 5.171875 \n",
       "L 49.421875 5.171875 \n",
       "L 49.421875 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-49\"/>\n",
       "       <path d=\"M 56.390625 67.921875 \n",
       "L 27.875 0 \n",
       "L 20.609375 0 \n",
       "L 47.796875 64.890625 \n",
       "L 14.109375 64.890625 \n",
       "L 14.109375 55.90625 \n",
       "L 8.40625 55.90625 \n",
       "L 8.40625 72.90625 \n",
       "L 56.390625 72.90625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-55\"/>\n",
       "       <path d=\"M 4.390625 30.609375 \n",
       "L 29.390625 30.609375 \n",
       "L 29.390625 23 \n",
       "L 4.390625 23 \n",
       "z\n",
       "\" id=\"DejaVuSerif-45\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(19.752023 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 111.999006 300.96 \n",
       "L 111.999006 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\"/>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 2017-03 -->\n",
       "      <defs>\n",
       "       <path d=\"M 9.71875 69.828125 \n",
       "Q 15.4375 71.96875 20.671875 73.09375 \n",
       "Q 25.921875 74.21875 30.515625 74.21875 \n",
       "Q 41.21875 74.21875 47.21875 69.59375 \n",
       "Q 53.21875 64.984375 53.21875 56.78125 \n",
       "Q 53.21875 50.203125 49.0625 45.78125 \n",
       "Q 44.921875 41.359375 37.3125 39.796875 \n",
       "Q 46.296875 38.53125 51.25 33.28125 \n",
       "Q 56.203125 28.03125 56.203125 19.671875 \n",
       "Q 56.203125 9.46875 49.34375 4.015625 \n",
       "Q 42.484375 -1.421875 29.59375 -1.421875 \n",
       "Q 23.875 -1.421875 18.421875 -0.1875 \n",
       "Q 12.984375 1.03125 7.625 3.515625 \n",
       "L 7.625 17.671875 \n",
       "L 13.09375 17.671875 \n",
       "Q 13.578125 10.640625 17.828125 7.03125 \n",
       "Q 22.078125 3.421875 29.78125 3.421875 \n",
       "Q 37.25 3.421875 41.578125 7.734375 \n",
       "Q 45.90625 12.0625 45.90625 19.578125 \n",
       "Q 45.90625 28.171875 41.453125 32.59375 \n",
       "Q 37.015625 37.015625 28.421875 37.015625 \n",
       "L 23.78125 37.015625 \n",
       "L 23.78125 42 \n",
       "L 26.21875 42 \n",
       "Q 34.765625 42 39.03125 45.53125 \n",
       "Q 43.3125 49.078125 43.3125 56.203125 \n",
       "Q 43.3125 62.59375 39.796875 65.984375 \n",
       "Q 36.28125 69.390625 29.6875 69.390625 \n",
       "Q 23.09375 69.390625 19.453125 66.265625 \n",
       "Q 15.828125 63.140625 15.1875 56.984375 \n",
       "L 9.71875 56.984375 \n",
       "z\n",
       "\" id=\"DejaVuSerif-51\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(74.971747 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-51\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 169.090586 300.96 \n",
       "L 169.090586 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\"/>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 2017-05 -->\n",
       "      <defs>\n",
       "       <path d=\"M 50.296875 72.90625 \n",
       "L 50.296875 64.890625 \n",
       "L 16.890625 64.890625 \n",
       "L 16.890625 44 \n",
       "Q 19.4375 45.75 22.828125 46.625 \n",
       "Q 26.21875 47.515625 30.421875 47.515625 \n",
       "Q 42.234375 47.515625 49.0625 40.96875 \n",
       "Q 55.90625 34.421875 55.90625 23.09375 \n",
       "Q 55.90625 11.53125 49 5.046875 \n",
       "Q 42.09375 -1.421875 29.59375 -1.421875 \n",
       "Q 24.5625 -1.421875 19.28125 -0.1875 \n",
       "Q 14.015625 1.03125 8.5 3.515625 \n",
       "L 8.5 17.671875 \n",
       "L 14.015625 17.671875 \n",
       "Q 14.453125 10.75 18.421875 7.078125 \n",
       "Q 22.40625 3.421875 29.59375 3.421875 \n",
       "Q 37.3125 3.421875 41.453125 8.5 \n",
       "Q 45.609375 13.578125 45.609375 23.09375 \n",
       "Q 45.609375 32.5625 41.484375 37.609375 \n",
       "Q 37.359375 42.671875 29.59375 42.671875 \n",
       "Q 25.203125 42.671875 21.84375 41.109375 \n",
       "Q 18.5 39.546875 15.921875 36.28125 \n",
       "L 11.71875 36.28125 \n",
       "L 11.71875 72.90625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-53\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(132.063327 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 226.182166 300.96 \n",
       "L 226.182166 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\"/>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- 2017-07 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(189.154907 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 284.209674 300.96 \n",
       "L 284.209674 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\"/>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 2017-09 -->\n",
       "      <defs>\n",
       "       <path d=\"M 46.78125 32.671875 \n",
       "Q 43.5 29 39.25 27.1875 \n",
       "Q 35.015625 25.390625 29.6875 25.390625 \n",
       "Q 18.84375 25.390625 12.5625 31.9375 \n",
       "Q 6.296875 38.484375 6.296875 49.8125 \n",
       "Q 6.296875 60.890625 13.109375 67.546875 \n",
       "Q 19.921875 74.21875 31.296875 74.21875 \n",
       "Q 43.65625 74.21875 50.265625 65.015625 \n",
       "Q 56.890625 55.8125 56.890625 38.71875 \n",
       "Q 56.890625 19.578125 49.015625 9.078125 \n",
       "Q 41.15625 -1.421875 26.90625 -1.421875 \n",
       "Q 23.046875 -1.421875 18.796875 -0.6875 \n",
       "Q 14.546875 0.046875 10.109375 1.515625 \n",
       "L 10.109375 13.625 \n",
       "L 15.578125 13.625 \n",
       "Q 16.21875 8.6875 19.390625 6.046875 \n",
       "Q 22.5625 3.421875 27.875 3.421875 \n",
       "Q 37.359375 3.421875 41.984375 10.5625 \n",
       "Q 46.625 17.71875 46.78125 32.671875 \n",
       "z\n",
       "M 30.90625 69.390625 \n",
       "Q 23.96875 69.390625 20.28125 64.328125 \n",
       "Q 16.609375 59.28125 16.609375 49.8125 \n",
       "Q 16.609375 40.328125 20.28125 35.25 \n",
       "Q 23.96875 30.171875 30.90625 30.171875 \n",
       "Q 37.84375 30.171875 41.53125 35.078125 \n",
       "Q 45.21875 39.984375 45.21875 49.21875 \n",
       "Q 45.21875 58.9375 41.5 64.15625 \n",
       "Q 37.796875 69.390625 30.90625 69.390625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-57\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(247.182415 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-57\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 341.301254 300.96 \n",
       "L 341.301254 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\"/>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 2017-11 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(304.273995 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 398.392834 300.96 \n",
       "L 398.392834 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\"/>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 2018-01 -->\n",
       "      <defs>\n",
       "       <path d=\"M 46.578125 19.921875 \n",
       "Q 46.578125 27.734375 42.6875 32.046875 \n",
       "Q 38.8125 36.375 31.78125 36.375 \n",
       "Q 24.75 36.375 20.875 32.046875 \n",
       "Q 17 27.734375 17 19.921875 \n",
       "Q 17 12.0625 20.875 7.734375 \n",
       "Q 24.75 3.421875 31.78125 3.421875 \n",
       "Q 38.8125 3.421875 42.6875 7.734375 \n",
       "Q 46.578125 12.0625 46.578125 19.921875 \n",
       "z\n",
       "M 44.578125 55.328125 \n",
       "Q 44.578125 61.96875 41.203125 65.671875 \n",
       "Q 37.84375 69.390625 31.78125 69.390625 \n",
       "Q 25.78125 69.390625 22.390625 65.671875 \n",
       "Q 19 61.96875 19 55.328125 \n",
       "Q 19 48.640625 22.390625 44.921875 \n",
       "Q 25.78125 41.21875 31.78125 41.21875 \n",
       "Q 37.84375 41.21875 41.203125 44.921875 \n",
       "Q 44.578125 48.640625 44.578125 55.328125 \n",
       "z\n",
       "M 39.3125 38.8125 \n",
       "Q 47.609375 37.703125 52.25 32.6875 \n",
       "Q 56.890625 27.6875 56.890625 19.921875 \n",
       "Q 56.890625 9.671875 50.390625 4.125 \n",
       "Q 43.890625 -1.421875 31.78125 -1.421875 \n",
       "Q 19.734375 -1.421875 13.203125 4.125 \n",
       "Q 6.6875 9.671875 6.6875 19.921875 \n",
       "Q 6.6875 27.6875 11.328125 32.6875 \n",
       "Q 15.96875 37.703125 24.3125 38.8125 \n",
       "Q 16.9375 40.140625 13 44.40625 \n",
       "Q 9.078125 48.6875 9.078125 55.328125 \n",
       "Q 9.078125 64.109375 15.125 69.15625 \n",
       "Q 21.1875 74.21875 31.78125 74.21875 \n",
       "Q 42.390625 74.21875 48.4375 69.15625 \n",
       "Q 54.5 64.109375 54.5 55.328125 \n",
       "Q 54.5 48.6875 50.5625 44.40625 \n",
       "Q 46.625 40.140625 39.3125 38.8125 \n",
       "z\n",
       "\" id=\"DejaVuSerif-56\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(361.365575 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-56\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 453.612559 300.96 \n",
       "L 453.612559 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\"/>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 2018-03 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(416.5853 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-56\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-51\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_9\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 510.704139 300.96 \n",
       "L 510.704139 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_18\"/>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 2018-05 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(473.67688 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-56\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_10\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 567.795719 300.96 \n",
       "L 567.795719 7.2 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_20\"/>\n",
       "     <g id=\"text_10\">\n",
       "      <!-- 2018-07 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(530.76846 335.317784)rotate(-30)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-49\"/>\n",
       "       <use x=\"190.869141\" xlink:href=\"#DejaVuSerif-56\"/>\n",
       "       <use x=\"254.492188\" xlink:href=\"#DejaVuSerif-45\"/>\n",
       "       <use x=\"288.28125\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "       <use x=\"351.904297\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_11\">\n",
       "     <!-- Date -->\n",
       "     <defs>\n",
       "      <path d=\"M 24.703125 5.171875 \n",
       "L 33.796875 5.171875 \n",
       "Q 48 5.171875 55.59375 13.28125 \n",
       "Q 63.1875 21.390625 63.1875 36.53125 \n",
       "Q 63.1875 51.65625 55.609375 59.65625 \n",
       "Q 48.046875 67.671875 33.796875 67.671875 \n",
       "L 24.703125 67.671875 \n",
       "z\n",
       "M 5.515625 0 \n",
       "L 5.515625 5.171875 \n",
       "L 14.796875 5.171875 \n",
       "L 14.796875 67.671875 \n",
       "L 5.515625 67.671875 \n",
       "L 5.515625 72.90625 \n",
       "L 34.515625 72.90625 \n",
       "Q 53.375 72.90625 63.890625 63.28125 \n",
       "Q 74.421875 53.65625 74.421875 36.53125 \n",
       "Q 74.421875 19.34375 63.875 9.671875 \n",
       "Q 53.328125 0 34.515625 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-68\"/>\n",
       "      <path d=\"M 39.796875 16.3125 \n",
       "L 39.796875 27.296875 \n",
       "L 28.21875 27.296875 \n",
       "Q 21.53125 27.296875 18.25 24.40625 \n",
       "Q 14.984375 21.53125 14.984375 15.578125 \n",
       "Q 14.984375 10.15625 18.296875 6.984375 \n",
       "Q 21.625 3.8125 27.296875 3.8125 \n",
       "Q 32.90625 3.8125 36.34375 7.28125 \n",
       "Q 39.796875 10.75 39.796875 16.3125 \n",
       "z\n",
       "M 48.78125 32.421875 \n",
       "L 48.78125 5.171875 \n",
       "L 56.78125 5.171875 \n",
       "L 56.78125 0 \n",
       "L 39.796875 0 \n",
       "L 39.796875 5.609375 \n",
       "Q 36.8125 2 32.90625 0.28125 \n",
       "Q 29 -1.421875 23.78125 -1.421875 \n",
       "Q 15.140625 -1.421875 10.0625 3.171875 \n",
       "Q 4.984375 7.765625 4.984375 15.578125 \n",
       "Q 4.984375 23.640625 10.796875 28.078125 \n",
       "Q 16.609375 32.515625 27.203125 32.515625 \n",
       "L 39.796875 32.515625 \n",
       "L 39.796875 36.078125 \n",
       "Q 39.796875 42 36.203125 45.234375 \n",
       "Q 32.625 48.484375 26.125 48.484375 \n",
       "Q 20.75 48.484375 17.578125 46.046875 \n",
       "Q 14.40625 43.609375 13.625 38.8125 \n",
       "L 8.984375 38.8125 \n",
       "L 8.984375 49.3125 \n",
       "Q 13.671875 51.3125 18.09375 52.3125 \n",
       "Q 22.515625 53.328125 26.703125 53.328125 \n",
       "Q 37.5 53.328125 43.140625 47.96875 \n",
       "Q 48.78125 42.625 48.78125 32.421875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-97\"/>\n",
       "      <path d=\"M 10.796875 46.6875 \n",
       "L 2.875 46.6875 \n",
       "L 2.875 51.90625 \n",
       "L 10.796875 51.90625 \n",
       "L 10.796875 68.015625 \n",
       "L 19.828125 68.015625 \n",
       "L 19.828125 51.90625 \n",
       "L 36.71875 51.90625 \n",
       "L 36.71875 46.6875 \n",
       "L 19.828125 46.6875 \n",
       "L 19.828125 13.71875 \n",
       "Q 19.828125 7.125 21.09375 5.265625 \n",
       "Q 22.359375 3.421875 25.78125 3.421875 \n",
       "Q 29.296875 3.421875 30.90625 5.484375 \n",
       "Q 32.515625 7.5625 32.625 12.203125 \n",
       "L 39.40625 12.203125 \n",
       "Q 39.015625 5.125 35.546875 1.84375 \n",
       "Q 32.078125 -1.421875 25 -1.421875 \n",
       "Q 17.234375 -1.421875 14.015625 2.015625 \n",
       "Q 10.796875 5.46875 10.796875 13.71875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-116\"/>\n",
       "      <path d=\"M 54.203125 25 \n",
       "L 15.484375 25 \n",
       "L 15.484375 24.609375 \n",
       "Q 15.484375 14.109375 19.4375 8.765625 \n",
       "Q 23.390625 3.421875 31.109375 3.421875 \n",
       "Q 37.015625 3.421875 40.796875 6.515625 \n",
       "Q 44.578125 9.625 46.09375 15.71875 \n",
       "L 53.328125 15.71875 \n",
       "Q 51.171875 7.171875 45.375 2.875 \n",
       "Q 39.59375 -1.421875 30.171875 -1.421875 \n",
       "Q 18.796875 -1.421875 11.890625 6.078125 \n",
       "Q 4.984375 13.578125 4.984375 25.984375 \n",
       "Q 4.984375 38.28125 11.765625 45.796875 \n",
       "Q 18.5625 53.328125 29.59375 53.328125 \n",
       "Q 41.359375 53.328125 47.65625 46.0625 \n",
       "Q 53.953125 38.8125 54.203125 25 \n",
       "z\n",
       "M 43.609375 30.171875 \n",
       "Q 43.3125 39.265625 39.765625 43.875 \n",
       "Q 36.234375 48.484375 29.59375 48.484375 \n",
       "Q 23.390625 48.484375 19.828125 43.84375 \n",
       "Q 16.265625 39.203125 15.484375 30.171875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-101\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(299.133047 349.477127)scale(0.11 -0.11)\">\n",
       "      <use xlink:href=\"#DejaVuSerif-68\"/>\n",
       "      <use x=\"80.175781\" xlink:href=\"#DejaVuSerif-97\"/>\n",
       "      <use x=\"139.794922\" xlink:href=\"#DejaVuSerif-116\"/>\n",
       "      <use x=\"179.980469\" xlink:href=\"#DejaVuSerif-101\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 33.2875 265.479542 \n",
       "L 591.2875 265.479542 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_22\"/>\n",
       "     <g id=\"text_12\">\n",
       "      <!-- 230 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 269.278761)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-51\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_23\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 33.2875 222.190957 \n",
       "L 591.2875 222.190957 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_24\"/>\n",
       "     <g id=\"text_13\">\n",
       "      <!-- 240 -->\n",
       "      <defs>\n",
       "       <path d=\"M 34.90625 24.703125 \n",
       "L 34.90625 63.484375 \n",
       "L 10.015625 24.703125 \n",
       "z\n",
       "M 56.390625 0 \n",
       "L 23.1875 0 \n",
       "L 23.1875 5.171875 \n",
       "L 34.90625 5.171875 \n",
       "L 34.90625 19.484375 \n",
       "L 3.078125 19.484375 \n",
       "L 3.078125 24.8125 \n",
       "L 35.015625 74.21875 \n",
       "L 44.671875 74.21875 \n",
       "L 44.671875 24.703125 \n",
       "L 58.59375 24.703125 \n",
       "L 58.59375 19.484375 \n",
       "L 44.671875 19.484375 \n",
       "L 44.671875 5.171875 \n",
       "L 56.390625 5.171875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-52\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 225.990176)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-52\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_25\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 33.2875 178.902372 \n",
       "L 591.2875 178.902372 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_26\"/>\n",
       "     <g id=\"text_14\">\n",
       "      <!-- 250 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 182.701591)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-53\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_27\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 33.2875 135.613787 \n",
       "L 591.2875 135.613787 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_28\"/>\n",
       "     <g id=\"text_15\">\n",
       "      <!-- 260 -->\n",
       "      <defs>\n",
       "       <path d=\"M 32.71875 3.421875 \n",
       "Q 39.59375 3.421875 43.296875 8.46875 \n",
       "Q 47.015625 13.53125 47.015625 23 \n",
       "Q 47.015625 32.46875 43.296875 37.515625 \n",
       "Q 39.59375 42.578125 32.71875 42.578125 \n",
       "Q 25.734375 42.578125 22.0625 37.6875 \n",
       "Q 18.40625 32.8125 18.40625 23.578125 \n",
       "Q 18.40625 13.875 22.109375 8.640625 \n",
       "Q 25.828125 3.421875 32.71875 3.421875 \n",
       "z\n",
       "M 16.796875 40.140625 \n",
       "Q 20.125 43.796875 24.3125 45.59375 \n",
       "Q 28.515625 47.40625 33.796875 47.40625 \n",
       "Q 44.671875 47.40625 51 40.859375 \n",
       "Q 57.328125 34.328125 57.328125 23 \n",
       "Q 57.328125 11.921875 50.515625 5.25 \n",
       "Q 43.703125 -1.421875 32.328125 -1.421875 \n",
       "Q 19.96875 -1.421875 13.328125 7.78125 \n",
       "Q 6.6875 17 6.6875 34.078125 \n",
       "Q 6.6875 53.21875 14.546875 63.71875 \n",
       "Q 22.40625 74.21875 36.71875 74.21875 \n",
       "Q 40.578125 74.21875 44.828125 73.484375 \n",
       "Q 49.078125 72.75 53.515625 71.296875 \n",
       "L 53.515625 59.28125 \n",
       "L 48 59.28125 \n",
       "Q 47.40625 64.203125 44.234375 66.796875 \n",
       "Q 41.0625 69.390625 35.6875 69.390625 \n",
       "Q 26.21875 69.390625 21.578125 62.203125 \n",
       "Q 16.9375 55.03125 16.796875 40.140625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-54\"/>\n",
       "      </defs>\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 139.413005)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-54\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_29\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 33.2875 92.325202 \n",
       "L 591.2875 92.325202 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_30\"/>\n",
       "     <g id=\"text_16\">\n",
       "      <!-- 270 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 96.12442)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-55\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_31\">\n",
       "      <path clip-path=\"url(#pbc5bebb174)\" d=\"M 33.2875 49.036616 \n",
       "L 591.2875 49.036616 \n",
       "\" style=\"fill:none;stroke:#ffffff;stroke-linecap:round;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_32\"/>\n",
       "     <g id=\"text_17\">\n",
       "      <!-- 280 -->\n",
       "      <g style=\"fill:#262626;\" transform=\"translate(7.2 52.835835)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSerif-50\"/>\n",
       "       <use x=\"63.623047\" xlink:href=\"#DejaVuSerif-56\"/>\n",
       "       <use x=\"127.246094\" xlink:href=\"#DejaVuSerif-48\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_33\">\n",
       "    <path clip-path=\"url(#pbc5bebb174)\" d=\"M 58.651136 286.084909 \n",
       "L 59.587064 280.284238 \n",
       "L 60.522991 281.063433 \n",
       "L 61.458919 277.557058 \n",
       "L 64.266702 280.803701 \n",
       "L 65.202629 280.803701 \n",
       "L 66.138557 278.033232 \n",
       "L 67.074484 280.500681 \n",
       "L 68.010412 278.249675 \n",
       "L 71.754122 281.712762 \n",
       "L 72.690049 279.548332 \n",
       "L 73.625977 283.184574 \n",
       "L 74.561905 279.591621 \n",
       "L 77.369687 282.145648 \n",
       "L 78.305615 275.868803 \n",
       "L 79.241542 267.340951 \n",
       "L 80.17747 268.379877 \n",
       "L 81.113397 269.938267 \n",
       "L 83.92118 276.085246 \n",
       "L 84.857108 276.171823 \n",
       "L 85.793035 275.782226 \n",
       "L 86.728963 275.132897 \n",
       "L 87.66489 268.336589 \n",
       "L 90.472673 270.111421 \n",
       "L 91.4086 270.068132 \n",
       "L 92.344528 268.769475 \n",
       "L 93.280455 262.882227 \n",
       "L 94.216383 258.942966 \n",
       "L 97.024166 253.488604 \n",
       "L 97.960093 249.462766 \n",
       "L 98.896021 244.181558 \n",
       "L 99.831948 245.04733 \n",
       "L 100.767876 243.445652 \n",
       "L 104.511586 237.38525 \n",
       "L 105.447513 238.294311 \n",
       "L 106.383441 237.601693 \n",
       "L 107.319369 236.303036 \n",
       "L 110.127151 234.701358 \n",
       "L 111.063079 237.471828 \n",
       "L 111.999006 223.143306 \n",
       "L 112.934934 229.679882 \n",
       "L 113.870861 229.030554 \n",
       "L 116.678644 232.104043 \n",
       "L 117.614571 235.177533 \n",
       "L 118.550499 237.08223 \n",
       "L 119.486427 235.783573 \n",
       "L 120.422354 232.19062 \n",
       "L 123.230137 231.671157 \n",
       "L 124.166064 235.610418 \n",
       "L 125.101992 226.736259 \n",
       "L 126.037919 228.770822 \n",
       "L 126.973847 235.047667 \n",
       "L 129.781629 236.17317 \n",
       "L 130.717557 249.3329 \n",
       "L 131.653485 246.952028 \n",
       "L 132.589412 248.034242 \n",
       "L 133.52534 248.770148 \n",
       "L 136.333122 249.809074 \n",
       "L 137.26905 242.450015 \n",
       "L 138.204977 241.497666 \n",
       "L 139.140905 238.251022 \n",
       "L 140.076832 240.631894 \n",
       "L 142.884615 242.406726 \n",
       "L 143.820543 241.757398 \n",
       "L 144.75647 244.787599 \n",
       "L 145.692398 241.930552 \n",
       "L 146.628325 242.969478 \n",
       "L 149.436108 242.363438 \n",
       "L 150.372035 243.575518 \n",
       "L 151.307963 248.034242 \n",
       "L 152.24389 254.614107 \n",
       "L 155.987601 245.696659 \n",
       "L 156.923528 248.72686 \n",
       "L 157.859456 250.588269 \n",
       "L 158.795383 242.363438 \n",
       "L 159.731311 245.610082 \n",
       "L 162.539093 234.441627 \n",
       "L 163.475021 228.467802 \n",
       "L 164.410949 229.117131 \n",
       "L 165.346876 228.251359 \n",
       "L 166.282804 230.502365 \n",
       "L 169.090586 227.90505 \n",
       "L 170.026514 227.515453 \n",
       "L 170.962441 228.770822 \n",
       "L 171.898369 227.558742 \n",
       "L 172.834296 223.489615 \n",
       "L 175.642079 223.662769 \n",
       "L 176.578007 224.615118 \n",
       "L 177.513934 222.753709 \n",
       "L 178.449862 224.874849 \n",
       "L 179.385789 226.606393 \n",
       "L 182.193572 220.8923 \n",
       "L 183.129499 221.844648 \n",
       "L 184.065427 240.285586 \n",
       "L 185.001354 236.17317 \n",
       "L 185.937282 229.506728 \n",
       "L 188.745065 224.268809 \n",
       "L 190.61692 219.550353 \n",
       "L 191.552847 214.572166 \n",
       "L 197.168412 215.957401 \n",
       "L 198.10434 207.645992 \n",
       "L 199.040268 204.139617 \n",
       "L 201.84805 204.918812 \n",
       "L 202.783978 208.295321 \n",
       "L 203.719905 206.347335 \n",
       "L 204.655833 205.827872 \n",
       "L 205.59176 207.42955 \n",
       "L 208.399543 207.645992 \n",
       "L 209.33547 202.494651 \n",
       "L 210.271398 203.836597 \n",
       "L 211.207326 205.87116 \n",
       "L 212.143253 210.762771 \n",
       "L 214.951036 202.018476 \n",
       "L 215.886963 209.161093 \n",
       "L 216.822891 209.420824 \n",
       "L 217.758818 209.896999 \n",
       "L 218.694746 208.64163 \n",
       "L 221.502529 207.949013 \n",
       "L 222.438456 216.433575 \n",
       "L 223.374384 207.083241 \n",
       "L 224.310311 216.346998 \n",
       "L 225.246239 214.399012 \n",
       "L 228.054021 212.62418 \n",
       "L 229.925876 210.200019 \n",
       "L 230.861804 219.810085 \n",
       "L 231.797731 213.057066 \n",
       "L 234.605514 211.931562 \n",
       "L 235.541442 212.710757 \n",
       "L 236.477369 204.832234 \n",
       "L 237.413297 203.057402 \n",
       "L 238.349224 198.122504 \n",
       "L 241.157007 198.252369 \n",
       "L 242.092934 197.689618 \n",
       "L 243.028862 191.932236 \n",
       "L 243.96479 191.456062 \n",
       "L 244.900717 192.40841 \n",
       "L 247.7085 192.668142 \n",
       "L 248.644427 190.070827 \n",
       "L 249.580355 190.027538 \n",
       "L 250.516282 191.023176 \n",
       "L 251.45221 192.278545 \n",
       "L 254.259992 192.884585 \n",
       "L 255.19592 190.503713 \n",
       "L 256.131848 189.98425 \n",
       "L 257.067775 192.062102 \n",
       "L 258.003703 190.114115 \n",
       "L 260.811485 188.122841 \n",
       "L 261.747413 190.763444 \n",
       "L 262.68334 190.806733 \n",
       "L 263.619268 205.914449 \n",
       "L 264.555195 204.35606 \n",
       "L 267.362978 193.880222 \n",
       "L 268.298906 194.010088 \n",
       "L 269.234833 192.148679 \n",
       "L 270.170761 208.814784 \n",
       "L 271.106688 210.45975 \n",
       "L 273.914471 209.637267 \n",
       "L 274.850398 198.641967 \n",
       "L 275.786326 202.451362 \n",
       "L 276.722253 204.918812 \n",
       "L 277.658181 202.451362 \n",
       "L 280.465964 202.408074 \n",
       "L 281.401891 201.195993 \n",
       "L 282.337819 196.174517 \n",
       "L 283.273746 189.767807 \n",
       "L 284.209674 188.252706 \n",
       "L 287.953384 195.958074 \n",
       "L 288.889311 192.321833 \n",
       "L 289.825239 192.451699 \n",
       "L 290.761167 193.707068 \n",
       "L 294.504877 178.685929 \n",
       "L 295.440804 178.166466 \n",
       "L 296.376732 178.512775 \n",
       "L 297.312659 182.408747 \n",
       "L 300.120442 180.114452 \n",
       "L 301.05637 179.032238 \n",
       "L 301.992297 178.64264 \n",
       "L 302.928225 181.542976 \n",
       "L 303.864152 181.326533 \n",
       "L 306.671935 183.53425 \n",
       "L 307.607862 182.884922 \n",
       "L 308.54379 178.685929 \n",
       "L 309.479717 177.387271 \n",
       "L 310.415645 173.577876 \n",
       "L 313.223428 168.85942 \n",
       "L 314.159355 166.521837 \n",
       "L 315.095283 165.223179 \n",
       "L 316.03121 158.729891 \n",
       "L 316.967138 159.98526 \n",
       "L 319.77492 161.803381 \n",
       "L 320.710848 158.903046 \n",
       "L 321.646775 157.171502 \n",
       "L 322.582703 158.816468 \n",
       "L 323.51863 157.474522 \n",
       "L 326.326413 156.00271 \n",
       "L 327.262341 155.223516 \n",
       "L 328.198268 154.141301 \n",
       "L 329.134196 153.838281 \n",
       "L 330.070123 148.124188 \n",
       "L 332.877906 152.453046 \n",
       "L 333.813833 150.50506 \n",
       "L 334.749761 156.00271 \n",
       "L 335.685689 154.574187 \n",
       "L 336.621616 145.526873 \n",
       "L 339.429399 149.682577 \n",
       "L 340.365326 147.951033 \n",
       "L 341.301254 146.479222 \n",
       "L 342.237181 146.046336 \n",
       "L 343.173109 142.323517 \n",
       "L 345.980891 140.591974 \n",
       "L 346.916819 141.371169 \n",
       "L 347.852747 139.466471 \n",
       "L 348.788674 143.535598 \n",
       "L 349.724602 143.881906 \n",
       "L 352.532384 142.84298 \n",
       "L 353.468312 145.440296 \n",
       "L 354.404239 151.024523 \n",
       "L 355.340167 141.587611 \n",
       "L 356.276094 144.877544 \n",
       "L 359.083877 142.972846 \n",
       "L 360.019805 135.657075 \n",
       "L 360.955732 136.652713 \n",
       "L 362.827587 134.055398 \n",
       "L 365.63537 134.618149 \n",
       "L 366.571297 123.189963 \n",
       "L 367.507225 123.88258 \n",
       "L 368.443152 113.926206 \n",
       "L 369.37908 116.307078 \n",
       "L 372.186863 117.692312 \n",
       "L 373.12279 121.804728 \n",
       "L 374.058718 121.588285 \n",
       "L 374.994645 117.995333 \n",
       "L 375.930573 111.761776 \n",
       "L 378.738355 108.298689 \n",
       "L 379.674283 106.264126 \n",
       "L 380.61021 106.393992 \n",
       "L 381.546138 111.112447 \n",
       "L 382.482066 107.432918 \n",
       "L 385.289848 100.117147 \n",
       "L 386.225776 104.575871 \n",
       "L 387.161703 105.181911 \n",
       "L 388.097631 102.801039 \n",
       "L 389.033558 103.104059 \n",
       "L 392.777269 104.489294 \n",
       "L 393.713196 103.926542 \n",
       "L 394.649124 101.54567 \n",
       "L 395.585051 105.917817 \n",
       "L 399.328761 97.649697 \n",
       "L 400.264689 90.290638 \n",
       "L 401.200616 85.355739 \n",
       "L 402.136544 77.520505 \n",
       "L 404.944327 75.356076 \n",
       "L 405.880254 72.672184 \n",
       "L 406.816182 74.490304 \n",
       "L 408.688037 58.040642 \n",
       "L 412.431747 62.153058 \n",
       "L 413.367674 50.724871 \n",
       "L 414.303602 52.759435 \n",
       "L 415.23953 47.261784 \n",
       "L 418.047312 37.391987 \n",
       "L 418.98324 34.794672 \n",
       "L 419.919167 35.270846 \n",
       "L 420.855095 34.751383 \n",
       "L 421.791022 20.552727 \n",
       "L 424.598805 28.777558 \n",
       "L 425.534732 41.417825 \n",
       "L 426.47066 40.811785 \n",
       "L 427.406588 42.19702 \n",
       "L 428.342515 68.732923 \n",
       "L 431.150298 118.601373 \n",
       "L 432.086225 96.091308 \n",
       "L 433.022153 102.411442 \n",
       "L 433.95808 145.873181 \n",
       "L 434.894008 129.120499 \n",
       "L 437.701791 112.497682 \n",
       "L 438.637718 109.640636 \n",
       "L 440.509573 79.20876 \n",
       "L 441.445501 78.862452 \n",
       "L 445.189211 86.2648 \n",
       "L 446.125138 92.108759 \n",
       "L 447.061066 90.593658 \n",
       "L 447.996993 71.936278 \n",
       "L 450.804776 58.127219 \n",
       "L 451.740704 73.148358 \n",
       "L 452.676631 85.182585 \n",
       "L 453.612559 102.281576 \n",
       "L 454.548486 96.307751 \n",
       "L 457.356269 82.845001 \n",
       "L 458.292196 79.858089 \n",
       "L 459.228124 80.290975 \n",
       "L 460.164051 74.576882 \n",
       "L 461.099979 53.928226 \n",
       "L 463.907762 55.443327 \n",
       "L 464.843689 63.235272 \n",
       "L 465.779617 69.382251 \n",
       "L 466.715544 70.680909 \n",
       "L 467.651472 74.143996 \n",
       "L 470.459254 90.204061 \n",
       "L 471.395182 88.212786 \n",
       "L 472.33111 90.463792 \n",
       "L 473.267037 119.726876 \n",
       "L 474.202965 144.055061 \n",
       "L 477.010747 113.49332 \n",
       "L 477.946675 133.016472 \n",
       "L 478.882602 136.349693 \n",
       "L 479.81853 121.977882 \n",
       "L 483.56224 146.565799 \n",
       "L 484.498168 132.280566 \n",
       "L 485.434095 120.20305 \n",
       "L 486.370023 111.199025 \n",
       "L 487.30595 136.825867 \n",
       "L 490.113733 131.284928 \n",
       "L 491.04966 113.320165 \n",
       "L 491.985588 119.337279 \n",
       "L 492.921515 109.943656 \n",
       "L 493.857443 113.320165 \n",
       "L 496.665226 103.883254 \n",
       "L 497.601153 91.502718 \n",
       "L 498.537081 90.636947 \n",
       "L 499.473008 97.130234 \n",
       "L 500.408936 107.000032 \n",
       "L 503.216718 107.173186 \n",
       "L 504.152646 122.713788 \n",
       "L 505.088573 119.90003 \n",
       "L 506.024501 108.298689 \n",
       "L 506.960429 107.216475 \n",
       "L 509.768211 116.090635 \n",
       "L 510.704139 114.056071 \n",
       "L 511.640066 121.761439 \n",
       "L 512.575994 124.272177 \n",
       "L 513.511921 109.554058 \n",
       "L 516.319704 105.658086 \n",
       "L 517.255631 105.658086 \n",
       "L 519.127487 83.580907 \n",
       "L 520.063414 79.987955 \n",
       "L 522.871197 79.425203 \n",
       "L 523.807124 87.563457 \n",
       "L 524.743052 82.628558 \n",
       "L 525.678979 83.624196 \n",
       "L 526.614907 86.56782 \n",
       "L 529.42269 77.736948 \n",
       "L 530.358617 81.026881 \n",
       "L 531.294545 77.780237 \n",
       "L 532.230472 80.204398 \n",
       "L 533.1664 83.018156 \n",
       "L 536.91011 96.567483 \n",
       "L 537.846037 81.026881 \n",
       "L 538.781965 88.256075 \n",
       "L 539.717892 76.741311 \n",
       "L 542.525675 71.113795 \n",
       "L 543.461603 70.248023 \n",
       "L 544.39753 60.291648 \n",
       "L 545.333458 60.421514 \n",
       "L 546.269385 56.87185 \n",
       "L 549.077168 55.270173 \n",
       "L 550.013095 53.711784 \n",
       "L 550.949023 57.564468 \n",
       "L 551.884951 54.534267 \n",
       "L 552.820878 61.46044 \n",
       "L 555.628661 63.92789 \n",
       "L 556.564588 68.51648 \n",
       "L 557.500516 66.481916 \n",
       "L 558.436443 73.970841 \n",
       "L 559.372371 71.806412 \n",
       "L 562.180153 87.996343 \n",
       "L 563.116081 85.399028 \n",
       "L 564.052009 95.13896 \n",
       "L 564.987936 88.472517 \n",
       "L 565.923864 86.784263 \n",
       "L 565.923864 86.784263 \n",
       "\" style=\"fill:none;stroke:#4c72b0;stroke-linecap:round;stroke-width:1.75;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_34\">\n",
       "    <path clip-path=\"url(#pbc5bebb174)\" d=\"M 58.651136 287.607273 \n",
       "L 59.587064 285.776514 \n",
       "L 60.522991 284.598244 \n",
       "L 61.458919 282.837947 \n",
       "L 64.266702 282.329386 \n",
       "L 65.202629 281.947965 \n",
       "L 66.138557 280.969282 \n",
       "L 67.074484 280.852131 \n",
       "L 68.010412 280.201517 \n",
       "L 71.754122 280.579328 \n",
       "L 72.690049 280.321579 \n",
       "L 73.625977 281.037328 \n",
       "L 74.561905 280.675901 \n",
       "L 77.369687 281.043338 \n",
       "L 78.305615 279.749704 \n",
       "L 79.241542 276.647516 \n",
       "L 80.17747 274.580606 \n",
       "L 81.113397 273.420021 \n",
       "L 83.92118 274.086327 \n",
       "L 84.857108 274.607701 \n",
       "L 85.793035 274.901332 \n",
       "L 86.728963 274.959223 \n",
       "L 87.66489 273.303565 \n",
       "L 90.472673 272.505529 \n",
       "L 91.4086 271.89618 \n",
       "L 92.344528 271.114503 \n",
       "L 93.280455 269.056434 \n",
       "L 94.216383 266.528067 \n",
       "L 97.024166 263.268201 \n",
       "L 97.960093 259.816843 \n",
       "L 98.896021 255.908021 \n",
       "L 100.767876 250.75605 \n",
       "L 104.511586 247.41335 \n",
       "L 105.447513 245.13359 \n",
       "L 107.319369 241.513721 \n",
       "L 111.063079 239.22593 \n",
       "L 111.999006 235.205274 \n",
       "L 113.870861 232.625583 \n",
       "L 116.678644 232.495198 \n",
       "L 117.614571 233.165782 \n",
       "L 118.550499 234.144894 \n",
       "L 119.486427 234.554563 \n",
       "L 120.422354 233.963578 \n",
       "L 123.230137 233.390473 \n",
       "L 124.166064 233.945459 \n",
       "L 125.101992 232.143159 \n",
       "L 126.037919 231.300075 \n",
       "L 126.973847 232.236973 \n",
       "L 129.781629 233.221022 \n",
       "L 130.717557 237.248992 \n",
       "L 131.653485 239.674751 \n",
       "L 132.589412 241.764624 \n",
       "L 133.52534 243.516005 \n",
       "L 136.333122 245.089272 \n",
       "L 138.204977 243.69651 \n",
       "L 139.140905 242.335138 \n",
       "L 140.076832 241.909327 \n",
       "L 143.820543 241.964607 \n",
       "L 144.75647 242.670355 \n",
       "L 145.692398 242.485404 \n",
       "L 146.628325 242.606423 \n",
       "L 149.436108 242.545676 \n",
       "L 150.372035 242.803137 \n",
       "L 151.307963 244.110913 \n",
       "L 152.24389 246.736712 \n",
       "L 155.987601 246.476699 \n",
       "L 156.923528 247.039239 \n",
       "L 157.859456 247.926496 \n",
       "L 158.795383 246.535732 \n",
       "L 159.731311 246.304319 \n",
       "L 162.539093 243.338646 \n",
       "L 163.475021 239.620935 \n",
       "L 164.410949 236.994984 \n",
       "L 165.346876 234.809078 \n",
       "L 166.282804 233.7324 \n",
       "L 169.090586 232.275562 \n",
       "L 170.026514 231.085535 \n",
       "L 170.962441 230.506857 \n",
       "L 171.898369 229.769828 \n",
       "L 172.834296 228.199775 \n",
       "L 175.642079 227.065523 \n",
       "L 176.578007 226.452922 \n",
       "L 177.513934 225.528119 \n",
       "L 178.449862 225.364801 \n",
       "L 179.385789 225.675199 \n",
       "L 182.193572 224.479474 \n",
       "L 183.129499 223.820768 \n",
       "L 184.065427 227.936972 \n",
       "L 185.001354 229.996022 \n",
       "L 185.937282 229.873698 \n",
       "L 188.745065 228.472476 \n",
       "L 190.61692 225.023577 \n",
       "L 191.552847 222.410725 \n",
       "L 192.488775 220.505196 \n",
       "L 196.232485 219.303314 \n",
       "L 197.168412 218.466836 \n",
       "L 199.040268 212.856123 \n",
       "L 202.783978 210.227677 \n",
       "L 204.655833 208.400161 \n",
       "L 205.59176 208.157508 \n",
       "L 208.399543 208.029629 \n",
       "L 209.33547 206.645885 \n",
       "L 210.271398 205.943563 \n",
       "L 211.207326 205.925462 \n",
       "L 212.143253 207.134789 \n",
       "L 214.951036 205.855711 \n",
       "L 216.822891 207.366749 \n",
       "L 217.758818 207.999311 \n",
       "L 218.694746 208.159891 \n",
       "L 221.502529 208.107171 \n",
       "L 222.438456 210.188772 \n",
       "L 223.374384 209.412389 \n",
       "L 224.310311 211.146042 \n",
       "L 225.246239 211.959284 \n",
       "L 228.054021 212.125508 \n",
       "L 229.925876 211.644136 \n",
       "L 230.861804 213.685623 \n",
       "L 234.605514 213.129253 \n",
       "L 235.541442 213.024629 \n",
       "L 237.413297 208.996748 \n",
       "L 238.349224 206.278187 \n",
       "L 241.157007 204.271733 \n",
       "L 242.092934 202.626204 \n",
       "L 243.028862 199.952712 \n",
       "L 243.96479 197.828549 \n",
       "L 244.900717 196.473515 \n",
       "L 247.7085 195.522172 \n",
       "L 248.644427 194.159335 \n",
       "L 249.580355 193.126386 \n",
       "L 250.516282 192.600583 \n",
       "L 251.45221 192.520074 \n",
       "L 254.259992 192.611202 \n",
       "L 256.131848 191.559309 \n",
       "L 257.067775 191.685008 \n",
       "L 258.003703 191.292284 \n",
       "L 260.811485 190.499924 \n",
       "L 262.68334 190.626036 \n",
       "L 263.619268 194.448139 \n",
       "L 264.555195 196.925119 \n",
       "L 267.362978 196.163895 \n",
       "L 268.298906 195.625443 \n",
       "L 269.234833 194.756252 \n",
       "L 270.170761 198.270885 \n",
       "L 271.106688 201.318102 \n",
       "L 273.914471 203.397893 \n",
       "L 274.850398 202.208911 \n",
       "L 275.786326 202.269524 \n",
       "L 276.722253 202.931846 \n",
       "L 277.658181 202.811725 \n",
       "L 280.465964 202.710812 \n",
       "L 281.401891 202.332107 \n",
       "L 282.337819 200.79271 \n",
       "L 284.209674 195.59054 \n",
       "L 287.953384 195.682423 \n",
       "L 288.889311 194.842276 \n",
       "L 289.825239 194.244632 \n",
       "L 290.761167 194.110241 \n",
       "L 293.568949 191.163223 \n",
       "L 294.504877 188.0439 \n",
       "L 295.440804 185.574541 \n",
       "L 296.376732 183.8091 \n",
       "L 297.312659 183.459011 \n",
       "L 300.120442 182.622872 \n",
       "L 301.992297 180.95457 \n",
       "L 306.671935 181.751978 \n",
       "L 307.607862 182.035214 \n",
       "L 309.479717 180.245237 \n",
       "L 310.415645 178.578397 \n",
       "L 313.223428 176.148653 \n",
       "L 315.095283 171.612256 \n",
       "L 316.03121 168.391665 \n",
       "L 316.967138 166.290064 \n",
       "L 319.77492 165.168393 \n",
       "L 321.646775 161.994418 \n",
       "L 323.51863 160.268578 \n",
       "L 326.326413 159.202111 \n",
       "L 329.134196 156.352762 \n",
       "L 330.070123 154.295618 \n",
       "L 332.877906 153.834975 \n",
       "L 333.813833 153.002496 \n",
       "L 334.749761 153.75255 \n",
       "L 335.685689 153.957959 \n",
       "L 336.621616 151.850188 \n",
       "L 339.429399 151.308285 \n",
       "L 340.365326 150.468972 \n",
       "L 342.237181 148.615235 \n",
       "L 343.173109 147.042305 \n",
       "L 345.980891 145.429723 \n",
       "L 346.916819 144.415084 \n",
       "L 347.852747 143.177931 \n",
       "L 349.724602 143.420987 \n",
       "L 352.532384 143.276486 \n",
       "L 353.468312 143.817438 \n",
       "L 354.404239 145.619209 \n",
       "L 355.340167 144.61131 \n",
       "L 356.276094 144.677868 \n",
       "L 359.083877 144.251613 \n",
       "L 360.019805 142.102978 \n",
       "L 360.955732 140.740412 \n",
       "L 362.827587 139.069158 \n",
       "L 365.63537 137.956406 \n",
       "L 366.571297 134.264795 \n",
       "L 367.507225 131.669241 \n",
       "L 368.443152 127.233482 \n",
       "L 369.37908 124.501881 \n",
       "L 372.186863 122.799489 \n",
       "L 374.058718 122.31017 \n",
       "L 374.994645 121.231461 \n",
       "L 375.930573 118.86404 \n",
       "L 378.738355 116.222702 \n",
       "L 379.674283 113.733058 \n",
       "L 380.61021 111.898292 \n",
       "L 381.546138 111.701831 \n",
       "L 382.482066 110.634602 \n",
       "L 386.225776 107.147897 \n",
       "L 387.161703 106.6564 \n",
       "L 388.097631 105.69256 \n",
       "L 389.033558 105.045435 \n",
       "L 392.777269 104.9064 \n",
       "L 393.713196 104.661435 \n",
       "L 394.649124 103.882494 \n",
       "L 395.585051 104.391325 \n",
       "L 399.328761 102.705918 \n",
       "L 400.264689 99.602098 \n",
       "L 401.200616 96.040508 \n",
       "L 402.136544 91.410508 \n",
       "L 404.944327 87.3969 \n",
       "L 405.880254 83.715721 \n",
       "L 406.816182 81.409367 \n",
       "L 407.752109 77.515172 \n",
       "L 408.688037 72.646539 \n",
       "L 412.431747 70.023169 \n",
       "L 413.367674 65.198594 \n",
       "L 414.303602 62.088805 \n",
       "L 415.23953 58.382049 \n",
       "L 418.047312 53.134534 \n",
       "L 418.98324 48.549568 \n",
       "L 419.919167 45.229888 \n",
       "L 420.855095 42.610262 \n",
       "L 421.791022 37.095878 \n",
       "L 424.598805 35.016298 \n",
       "L 425.534732 36.61668 \n",
       "L 427.406588 38.798347 \n",
       "L 428.342515 46.281991 \n",
       "L 431.150298 64.361836 \n",
       "L 433.022153 79.823514 \n",
       "L 433.95808 96.335931 \n",
       "L 434.894008 104.532073 \n",
       "L 438.637718 107.302765 \n",
       "L 439.573646 104.002082 \n",
       "L 440.509573 97.803752 \n",
       "L 441.445501 93.068427 \n",
       "L 445.189211 91.36752 \n",
       "L 446.125138 91.55283 \n",
       "L 447.061066 91.313037 \n",
       "L 447.996993 86.468847 \n",
       "L 450.804776 79.38344 \n",
       "L 451.740704 77.82467 \n",
       "L 452.676631 79.664148 \n",
       "L 453.612559 85.318505 \n",
       "L 454.548486 88.065817 \n",
       "L 457.356269 86.760613 \n",
       "L 458.292196 85.034982 \n",
       "L 459.228124 83.84898 \n",
       "L 460.164051 81.530956 \n",
       "L 461.099979 74.630273 \n",
       "L 464.843689 68.183971 \n",
       "L 465.779617 68.483541 \n",
       "L 466.715544 69.032883 \n",
       "L 467.651472 70.310661 \n",
       "L 470.459254 75.284011 \n",
       "L 472.33111 81.503102 \n",
       "L 473.267037 91.059045 \n",
       "L 474.202965 104.308049 \n",
       "L 477.010747 106.604367 \n",
       "L 477.946675 113.207393 \n",
       "L 478.882602 118.992968 \n",
       "L 479.81853 119.739196 \n",
       "L 484.498168 127.904527 \n",
       "L 485.434095 125.979158 \n",
       "L 486.370023 122.284124 \n",
       "L 487.30595 125.91956 \n",
       "L 490.113733 127.260902 \n",
       "L 491.04966 123.775718 \n",
       "L 491.985588 122.666108 \n",
       "L 492.921515 119.485495 \n",
       "L 493.857443 117.944163 \n",
       "L 496.665226 114.428935 \n",
       "L 497.601153 108.697381 \n",
       "L 498.537081 104.182273 \n",
       "L 499.473008 102.419263 \n",
       "L 500.408936 103.564455 \n",
       "L 503.216718 104.466638 \n",
       "L 504.152646 109.028426 \n",
       "L 505.088573 111.746327 \n",
       "L 506.960429 109.967432 \n",
       "L 509.768211 111.498233 \n",
       "L 510.704139 112.137692 \n",
       "L 512.575994 116.975766 \n",
       "L 513.511921 115.120339 \n",
       "L 516.319704 112.754776 \n",
       "L 517.255631 110.980603 \n",
       "L 518.191559 106.85786 \n",
       "L 520.063414 95.775955 \n",
       "L 522.871197 91.688267 \n",
       "L 523.807124 90.657065 \n",
       "L 524.743052 88.649938 \n",
       "L 525.678979 87.393503 \n",
       "L 526.614907 87.187082 \n",
       "L 529.42269 84.824548 \n",
       "L 530.358617 83.875132 \n",
       "L 531.294545 82.351408 \n",
       "L 532.230472 81.814655 \n",
       "L 533.1664 82.11553 \n",
       "L 536.91011 85.728519 \n",
       "L 537.846037 84.553109 \n",
       "L 538.781965 85.47885 \n",
       "L 539.717892 83.294466 \n",
       "L 542.525675 80.249298 \n",
       "L 543.461603 77.748979 \n",
       "L 544.39753 73.384646 \n",
       "L 546.269385 66.82586 \n",
       "L 549.077168 63.936938 \n",
       "L 550.013095 61.38065 \n",
       "L 550.949023 60.426604 \n",
       "L 551.884951 58.95352 \n",
       "L 552.820878 59.58025 \n",
       "L 555.628661 60.66716 \n",
       "L 556.564588 62.62949 \n",
       "L 557.500516 63.592596 \n",
       "L 558.436443 66.187158 \n",
       "L 559.372371 67.591971 \n",
       "L 562.180153 72.693064 \n",
       "L 563.116081 75.869555 \n",
       "L 564.052009 80.686906 \n",
       "L 564.987936 82.633309 \n",
       "L 565.923864 83.671047 \n",
       "L 565.923864 83.671047 \n",
       "\" style=\"fill:none;stroke:#55a868;stroke-linecap:round;stroke-width:1.75;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 33.2875 300.96 \n",
       "L 33.2875 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 591.2875 300.96 \n",
       "L 591.2875 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 33.2875 300.96 \n",
       "L 591.2875 300.96 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 33.2875 7.2 \n",
       "L 591.2875 7.2 \n",
       "\" style=\"fill:none;\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"line2d_35\">\n",
       "     <path d=\"M 519.248438 20.298437 \n",
       "L 539.248438 20.298437 \n",
       "\" style=\"fill:none;stroke:#4c72b0;stroke-linecap:round;stroke-width:1.75;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_36\"/>\n",
       "    <g id=\"text_18\">\n",
       "     <!-- SPY -->\n",
       "     <defs>\n",
       "      <path d=\"M 9.28125 3.515625 \n",
       "L 9.28125 20.125 \n",
       "L 14.890625 20.0625 \n",
       "Q 15.140625 11.765625 19.703125 7.78125 \n",
       "Q 24.265625 3.8125 33.59375 3.8125 \n",
       "Q 42.28125 3.8125 46.84375 7.25 \n",
       "Q 51.421875 10.6875 51.421875 17.28125 \n",
       "Q 51.421875 22.5625 48.65625 25.390625 \n",
       "Q 45.90625 28.21875 37.015625 30.90625 \n",
       "L 27.390625 33.796875 \n",
       "Q 16.9375 36.96875 12.671875 41.703125 \n",
       "Q 8.40625 46.4375 8.40625 54.6875 \n",
       "Q 8.40625 63.96875 14.984375 69.09375 \n",
       "Q 21.578125 74.21875 33.5 74.21875 \n",
       "Q 38.578125 74.21875 44.625 73.109375 \n",
       "Q 50.6875 72.015625 57.515625 69.921875 \n",
       "L 57.515625 54.390625 \n",
       "L 52 54.390625 \n",
       "Q 51.171875 62.109375 46.84375 65.546875 \n",
       "Q 42.53125 69 33.6875 69 \n",
       "Q 25.984375 69 21.953125 65.84375 \n",
       "Q 17.921875 62.703125 17.921875 56.6875 \n",
       "Q 17.921875 51.46875 20.9375 48.484375 \n",
       "Q 23.96875 45.515625 33.796875 42.578125 \n",
       "L 42.828125 39.890625 \n",
       "Q 52.734375 36.921875 56.953125 32.296875 \n",
       "Q 61.1875 27.6875 61.1875 19.921875 \n",
       "Q 61.1875 9.328125 54.390625 3.953125 \n",
       "Q 47.609375 -1.421875 34.1875 -1.421875 \n",
       "Q 28.171875 -1.421875 21.9375 -0.1875 \n",
       "Q 15.71875 1.03125 9.28125 3.515625 \n",
       "z\n",
       "\" id=\"DejaVuSerif-83\"/>\n",
       "      <path d=\"M 24.703125 37.109375 \n",
       "L 37.59375 37.109375 \n",
       "Q 44.875 37.109375 48.671875 41.03125 \n",
       "Q 52.484375 44.96875 52.484375 52.390625 \n",
       "Q 52.484375 59.859375 48.671875 63.765625 \n",
       "Q 44.875 67.671875 37.59375 67.671875 \n",
       "L 24.703125 67.671875 \n",
       "z\n",
       "M 5.515625 0 \n",
       "L 5.515625 5.171875 \n",
       "L 14.796875 5.171875 \n",
       "L 14.796875 67.671875 \n",
       "L 5.515625 67.671875 \n",
       "L 5.515625 72.90625 \n",
       "L 39.984375 72.90625 \n",
       "Q 50.921875 72.90625 57.3125 67.359375 \n",
       "Q 63.71875 61.8125 63.71875 52.390625 \n",
       "Q 63.71875 43.015625 57.3125 37.453125 \n",
       "Q 50.921875 31.890625 39.984375 31.890625 \n",
       "L 24.703125 31.890625 \n",
       "L 24.703125 5.171875 \n",
       "L 35.984375 5.171875 \n",
       "L 35.984375 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-80\"/>\n",
       "      <path d=\"M 18.890625 0 \n",
       "L 18.890625 5.171875 \n",
       "L 28.21875 5.171875 \n",
       "L 28.21875 31.390625 \n",
       "L 5.71875 67.671875 \n",
       "L -1.125 67.671875 \n",
       "L -1.125 72.90625 \n",
       "L 25.984375 72.90625 \n",
       "L 25.984375 67.671875 \n",
       "L 17.484375 67.671875 \n",
       "L 35.6875 38.1875 \n",
       "L 53.90625 67.671875 \n",
       "L 45.703125 67.671875 \n",
       "L 45.703125 72.90625 \n",
       "L 66.890625 72.90625 \n",
       "L 66.890625 67.671875 \n",
       "L 60.015625 67.671875 \n",
       "L 38.09375 32.328125 \n",
       "L 38.09375 5.171875 \n",
       "L 47.40625 5.171875 \n",
       "L 47.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-89\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(547.248438 23.798437)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSerif-83\"/>\n",
       "      <use x=\"68.505859\" xlink:href=\"#DejaVuSerif-80\"/>\n",
       "      <use x=\"135.791016\" xlink:href=\"#DejaVuSerif-89\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_37\">\n",
       "     <path d=\"M 519.248438 34.976562 \n",
       "L 539.248438 34.976562 \n",
       "\" style=\"fill:none;stroke:#55a868;stroke-linecap:round;stroke-width:1.75;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_38\"/>\n",
       "    <g id=\"text_19\">\n",
       "     <!-- EWMA -->\n",
       "     <defs>\n",
       "      <path d=\"M 5.515625 0 \n",
       "L 5.515625 5.171875 \n",
       "L 14.796875 5.171875 \n",
       "L 14.796875 67.671875 \n",
       "L 5.515625 67.671875 \n",
       "L 5.515625 72.90625 \n",
       "L 64.203125 72.90625 \n",
       "L 64.203125 56.6875 \n",
       "L 58.203125 56.6875 \n",
       "L 58.203125 66.890625 \n",
       "L 24.703125 66.890625 \n",
       "L 24.703125 42.484375 \n",
       "L 48.578125 42.484375 \n",
       "L 48.578125 51.609375 \n",
       "L 54.59375 51.609375 \n",
       "L 54.59375 27.390625 \n",
       "L 48.578125 27.390625 \n",
       "L 48.578125 36.53125 \n",
       "L 24.703125 36.53125 \n",
       "L 24.703125 6 \n",
       "L 58.984375 6 \n",
       "L 58.984375 16.21875 \n",
       "L 64.984375 16.21875 \n",
       "L 64.984375 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-69\"/>\n",
       "      <path d=\"M 76.21875 0 \n",
       "L 68.21875 0 \n",
       "L 51.515625 59.28125 \n",
       "L 34.8125 0 \n",
       "L 26.8125 0 \n",
       "L 7.71875 67.671875 \n",
       "L 0.484375 67.671875 \n",
       "L 0.484375 72.90625 \n",
       "L 27.09375 72.90625 \n",
       "L 27.09375 67.671875 \n",
       "L 18.015625 67.671875 \n",
       "L 33.203125 13.8125 \n",
       "L 49.8125 72.90625 \n",
       "L 57.71875 72.90625 \n",
       "L 74.609375 13.1875 \n",
       "L 89.890625 67.671875 \n",
       "L 81.5 67.671875 \n",
       "L 81.5 72.90625 \n",
       "L 102.484375 72.90625 \n",
       "L 102.484375 67.671875 \n",
       "L 95.3125 67.671875 \n",
       "z\n",
       "\" id=\"DejaVuSerif-87\"/>\n",
       "      <path d=\"M 5.515625 0 \n",
       "L 5.515625 5.171875 \n",
       "L 14.796875 5.171875 \n",
       "L 14.796875 67.671875 \n",
       "L 4.984375 67.671875 \n",
       "L 4.984375 72.90625 \n",
       "L 26.21875 72.90625 \n",
       "L 51.8125 21 \n",
       "L 77.390625 72.90625 \n",
       "L 97.3125 72.90625 \n",
       "L 97.3125 67.671875 \n",
       "L 87.59375 67.671875 \n",
       "L 87.59375 5.171875 \n",
       "L 96.921875 5.171875 \n",
       "L 96.921875 0 \n",
       "L 68.40625 0 \n",
       "L 68.40625 5.171875 \n",
       "L 77.6875 5.171875 \n",
       "L 77.6875 61.53125 \n",
       "L 52.6875 10.6875 \n",
       "L 45.796875 10.6875 \n",
       "L 20.796875 61.53125 \n",
       "L 20.796875 5.171875 \n",
       "L 30.078125 5.171875 \n",
       "L 30.078125 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-77\"/>\n",
       "      <path d=\"M 20.015625 26.421875 \n",
       "L 46.78125 26.421875 \n",
       "L 33.40625 61.078125 \n",
       "z\n",
       "M -0.59375 0 \n",
       "L -0.59375 5.171875 \n",
       "L 5.8125 5.171875 \n",
       "L 31.78125 72.90625 \n",
       "L 39.984375 72.90625 \n",
       "L 66.015625 5.171875 \n",
       "L 73.1875 5.171875 \n",
       "L 73.1875 0 \n",
       "L 46.6875 0 \n",
       "L 46.6875 5.171875 \n",
       "L 54.78125 5.171875 \n",
       "L 48.6875 21.1875 \n",
       "L 18.015625 21.1875 \n",
       "L 11.921875 5.171875 \n",
       "L 19.921875 5.171875 \n",
       "L 19.921875 0 \n",
       "z\n",
       "\" id=\"DejaVuSerif-65\"/>\n",
       "     </defs>\n",
       "     <g style=\"fill:#262626;\" transform=\"translate(547.248438 38.476562)scale(0.1 -0.1)\">\n",
       "      <use xlink:href=\"#DejaVuSerif-69\"/>\n",
       "      <use x=\"72.998047\" xlink:href=\"#DejaVuSerif-87\"/>\n",
       "      <use x=\"175.78125\" xlink:href=\"#DejaVuSerif-77\"/>\n",
       "      <use x=\"278.173828\" xlink:href=\"#DejaVuSerif-65\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pbc5bebb174\">\n",
       "   <rect height=\"293.76\" width=\"558\" x=\"33.2875\" y=\"7.2\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 720x432 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "data[data.index > '2017-1-1'].plot(figsize=(10, 6));\n",
    "# plt.savefig('../../images/ch10/perf_03.png');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pure Python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ewma_py(x, alpha):\n",
    "    y = np.zeros_like(x)\n",
    "    y[0] = x[0]\n",
    "    for i in range(1, len(x)):\n",
    "        y[i] = alpha * x[i] + (1-alpha) * y[i-1]\n",
    "    return y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 5.28 ms, sys: 52 µs, total: 5.34 ms\n",
      "Wall time: 5.31 ms\n"
     ]
    }
   ],
   "source": [
    "%time data['EWMA_PY'] = ewma_py(data[sym], alpha)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 950 µs, sys: 19 µs, total: 969 µs\n",
      "Wall time: 957 µs\n"
     ]
    }
   ],
   "source": [
    "%time data['EWMA_PY'] = ewma_py(data[sym].values, alpha)  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Numba"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "metadata": {},
   "outputs": [],
   "source": [
    "ewma_nb = numba.jit(ewma_py)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 101 ms, sys: 12.8 ms, total: 114 ms\n",
      "Wall time: 114 ms\n"
     ]
    }
   ],
   "source": [
    "%time data['EWMA_NB'] = ewma_nb(data[sym].values, alpha)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "87 µs ± 1.55 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit data['EWMA_NB'] = ewma_nb(data[sym].values, alpha)  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cython"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%cython\n",
    "import numpy as np\n",
    "cimport cython\n",
    "@cython.boundscheck(False)\n",
    "@cython.wraparound(False)\n",
    "def ewma_cy(double[:] x, float alpha):\n",
    "    cdef int i\n",
    "    cdef double[:] y = np.empty_like(x)\n",
    "    y[0] = x[0]\n",
    "    for i in range(1, len(x)):\n",
    "        y[i] = alpha * x[i] + (1 - alpha) * y[i - 1]\n",
    "    return y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 1.81 ms, sys: 1.46 ms, total: 3.27 ms\n",
      "Wall time: 3.21 ms\n"
     ]
    }
   ],
   "source": [
    "%time data['EWMA_CY'] = ewma_cy(data[sym].values, alpha)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "469 µs ± 8.85 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%timeit data['EWMA_CY'] = ewma_cy(data[sym].values, alpha)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SPY</th>\n",
       "      <th>EWMA</th>\n",
       "      <th>EWMA_PY</th>\n",
       "      <th>EWMA_NB</th>\n",
       "      <th>EWMA_CY</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2010-01-04</th>\n",
       "      <td>113.33</td>\n",
       "      <td>113.330000</td>\n",
       "      <td>113.330000</td>\n",
       "      <td>113.330000</td>\n",
       "      <td>113.330000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-05</th>\n",
       "      <td>113.63</td>\n",
       "      <td>113.405000</td>\n",
       "      <td>113.405000</td>\n",
       "      <td>113.405000</td>\n",
       "      <td>113.405000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-06</th>\n",
       "      <td>113.71</td>\n",
       "      <td>113.481250</td>\n",
       "      <td>113.481250</td>\n",
       "      <td>113.481250</td>\n",
       "      <td>113.481250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-07</th>\n",
       "      <td>114.19</td>\n",
       "      <td>113.658438</td>\n",
       "      <td>113.658438</td>\n",
       "      <td>113.658438</td>\n",
       "      <td>113.658438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2010-01-08</th>\n",
       "      <td>114.57</td>\n",
       "      <td>113.886328</td>\n",
       "      <td>113.886328</td>\n",
       "      <td>113.886328</td>\n",
       "      <td>113.886328</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               SPY        EWMA     EWMA_PY     EWMA_NB     EWMA_CY\n",
       "Date                                                              \n",
       "2010-01-04  113.33  113.330000  113.330000  113.330000  113.330000\n",
       "2010-01-05  113.63  113.405000  113.405000  113.405000  113.405000\n",
       "2010-01-06  113.71  113.481250  113.481250  113.481250  113.481250\n",
       "2010-01-07  114.19  113.658438  113.658438  113.658438  113.658438\n",
       "2010-01-08  114.57  113.886328  113.886328  113.886328  113.886328"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SPY</th>\n",
       "      <th>EWMA</th>\n",
       "      <th>EWMA_PY</th>\n",
       "      <th>EWMA_NB</th>\n",
       "      <th>EWMA_CY</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-06-25</th>\n",
       "      <td>271.00</td>\n",
       "      <td>274.535176</td>\n",
       "      <td>274.535176</td>\n",
       "      <td>274.535176</td>\n",
       "      <td>274.535176</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-26</th>\n",
       "      <td>271.60</td>\n",
       "      <td>273.801382</td>\n",
       "      <td>273.801382</td>\n",
       "      <td>273.801382</td>\n",
       "      <td>273.801382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-27</th>\n",
       "      <td>269.35</td>\n",
       "      <td>272.688537</td>\n",
       "      <td>272.688537</td>\n",
       "      <td>272.688537</td>\n",
       "      <td>272.688537</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-28</th>\n",
       "      <td>270.89</td>\n",
       "      <td>272.238903</td>\n",
       "      <td>272.238903</td>\n",
       "      <td>272.238903</td>\n",
       "      <td>272.238903</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-29</th>\n",
       "      <td>271.28</td>\n",
       "      <td>271.999177</td>\n",
       "      <td>271.999177</td>\n",
       "      <td>271.999177</td>\n",
       "      <td>271.999177</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               SPY        EWMA     EWMA_PY     EWMA_NB     EWMA_CY\n",
       "Date                                                              \n",
       "2018-06-25  271.00  274.535176  274.535176  274.535176  274.535176\n",
       "2018-06-26  271.60  273.801382  273.801382  273.801382  273.801382\n",
       "2018-06-27  269.35  272.688537  272.688537  272.688537  272.688537\n",
       "2018-06-28  270.89  272.238903  272.238903  272.238903  272.238903\n",
       "2018-06-29  271.28  271.999177  271.999177  271.999177  271.999177"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"http://hilpisch.com/tpq_logo.png\" alt=\"The Python Quants\" width=\"35%\" align=\"right\" border=\"0\"><br>\n",
    "\n",
    "<a href=\"http://tpq.io\" target=\"_blank\">http://tpq.io</a> | <a href=\"http://twitter.com/dyjh\" target=\"_blank\">@dyjh</a> | <a href=\"mailto:training@tpq.io\">training@tpq.io</a>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
